serverless / serverless-plugin-typescript

Serverless plugin for zero-config Typescript support
MIT License
783 stars 222 forks source link

When using promises (async await), nothing is returned #88

Open rafaelcorreiapoli opened 6 years ago

rafaelcorreiapoli commented 6 years ago

Hello! I've set up the project correctly. When I invoke locally the following code

const fetchSomething = () => new Promise((resolve, reject) => {
  setTimeout(() => {
    resolve({
      some: 'thing',
    })
  }, 1000)
})

export const asyncTest = async (event: APIGatewayEvent) => {
  const x = await fetchSomething()
  return {
    statusCode: 200,
    body: JSON.stringify(x),
  }
}

Nothing is returned.

I've tested using callbacks in this same project and it works as expected

DanielSchaffer commented 6 years ago

You need to make sure that your serverless project is using node8.10 as its runtime ... async won't work before that.