Netlify Functions + axios Get not working in production

Hi @ambim,

Getting Functions do async tasks can be tricky, but what usually works for me is the following format:

return axis(config).then(response => {
  return {
    statusCode: 200,
    body: JSON.stringify(response.data)
  }
}).catch(error => {
  console.log(error)
  return {
    statusCode: 422
    body: `Error: ${error}`,
  }
})

Basically, instead of using the async keyword, the return statement does the trick. Could you try this and let us know if it works?

Do note that, we do not actually provide help with custom code as that’s beyond the scope of support, but this was a small change and could possibly work.

1 Like