I play with AWS Lambda using Node.js. After you got tired of calling callbacks, I decided that I could elegantly use async/await
it just like I was used to C #.
exports.handler = async(event, context, callback) => {
db = await MongoClient.connect(process.env['MONGODB_URI']);
}
Although this seems to work when testing offline using lambda-local
, it loads with an error in AWS. It seems that the keyword is async
not recognized. I am using the latest version of Node.js 6.10 on AWS, while my local version is 8.5. Is there a way, or should I abandon this approach and return to using callbacks?
source
share