DEV Community

Discussion on: Common Node.js mistakes in Lambda

Collapse
 
fjanon profile image
Fred Janon

Why using a callback instead of an async function would be a mistake? Why wouldn't the callback work or be less efficient?

Collapse
 
theburningmonk profile image
Yan Cui

You can use callback instead of async, but probably shouldn't mix the two as it gives off the impression that you can return early before the async function's promise resolves. Which is not the case, the Lambda invocation will finish and return to the caller with a response when the async function's promise resolves at the end.