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

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Bablo
  • 59
  • 7

1 Answers1

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.