2

I'm working on a small serverless offline assignment and I got error Unsupported Media Type when tried to invoke one lambda function in another.

I found a solution but when I tried to applied to my project was not working: here in the link all the details. cloud anyone help me with that

https://github.com/dherault/serverless-offline/issues/1005#issue-632401297

1 Answer 1

0

there are three possible solutions.

  1. Make sure that the lambda_A have the same port and host where the lambda_B is running.

Lambda_A:

const { Lambda } = require('aws-sdk');

const lambda = new Lambda({
  region: 'us-east-1',
  endpoint: 'http://localhost:3000',
});

module.exports.main = async (event, context) => {
  // invoke
}

Lambda_B: Is running on http://localhost:3000

  1. You have configured out serverless-offline in twice functions.

https://www.serverless.com/plugins/serverless-offline#usage-with-invoke

  1. Lambda_A or Lambda_B have correctly stage?. Remember to use sls offline --stage local in both functions.
1
  • 1
    The port used in the endpoint needs to be the value of --lambdaPort CLI option. The default is 3002. Sep 16, 2022 at 5:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.