question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

APIGateway returns lambda response object instead of body of the response

See original GitHub issue

My code:

export function handler(event: APIGatewayEvent, context: Context) {
  try {
    const app: Application = getExpressApp();
    const server = awsServerlessExpress.createServer(app);
    return awsServerlessExpress.proxy(server, event, context);
  } catch (err) {
    context.fail('Failed to start server on lambda');
  }
}

The response if a make a request through api gateway: body

But i was expecting to just get the json body:

{
  "message": "hello from backend"
}

Am i doing something wrong or is this expected behavior?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
emrahayanoglucommented, Jul 19, 2018

I found my problem on the response which is the wrong configuration of the API Gateway. It should be configured as Lambda Proxy Integration, otherwise all headers will be visible on the response.

I propose to close this ticket as it is a configuration issue on the API Gateway.

0reactions
brettstackcommented, Jul 19, 2018

Glad you figured it out. Thanks for the screenshots. Check out our example which I recommend using as a baseline and modifying from there. It uses SAM a d is a one-command deploy

Read more comments on GitHub >

github_iconTop Results From Across the Web

APIGateway returns lambda response object instead of ...
I found my problem on the response which is the wrong configuration of the API Gateway. It should be configured as Lambda Proxy...
Read more >
Set up an integration response in API Gateway
There is no need to map the Lambda function response to its proper HTTP response. To return the result to the client, set...
Read more >
How to correctly formate the response for an AWS Lambda API?
I am using Api-Gateway to create an API that return the result of a Lambda. I am used to API responses in the...
Read more >
API Gateway integration response setup for AWS Lambda
It's a very common strategy to create your function in AWS Lambda and create REST API on API Gateway and integrate them together,...
Read more >
Integrating API Gateway — Lambda Responses - Medium
My Use Case. I shall focus on a Lambda function which may throw unexpected exceptions, errors and return a response. To make this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found