最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

amazon web services - AWS Serverless function async: true - Stack Overflow

programmeradmin1浏览0评论

In the Serverless framework built with AWS, when a function is kept as

async: true

it immediately returns a 200 HTTP response, can we override this status codes. Can somebody answer to this thanks

I have tried to return response objects in multiple ways but the statusCode is always set to 200

return {
statusCode: 400
}

In the Serverless framework built with AWS, when a function is kept as

async: true

it immediately returns a 200 HTTP response, can we override this status codes. Can somebody answer to this thanks

I have tried to return response objects in multiple ways but the statusCode is always set to 200

return {
statusCode: 400
}
Share Improve this question asked 22 hours ago K. AnirudhK. Anirudh 131 silver badge2 bronze badges New contributor K. Anirudh is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Add a comment  | 

1 Answer 1

Reset to default 1

What you are asking for doesn't make sense. The whole purpose of invoking a function asynchronously is to invoke it and let it run without waiting for the response. The code you are changing runs at some time after you get that 200 response code.

The Lambda function isn't returning the response from an async call, the AWS Lambda service is returning that response. The service is letting you know it has started to invoke your Lambda function. Why would you want a 400 error code to be returned from that scenario?

If you care about the Lambda function's response code, you can't call it asynchronously, you have to call it synchronously, so that you wait for the function to actually run and return a response to you.

发布评论

评论列表(0)

  1. 暂无评论