The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

611248 (3) [Avatar] Offline
#1
I took the class to learn serverless but I feel the javascript style is verbose and a distraction. I don't have background on the co package but I feel it's so verbose that when I write code I'm going to find another way.

If it was possible to write more concise code without that extra that would have been great.

For what I understand we keep asking to be asynchronous then just after we ask to do it right away like yield on first line of:
module.exports.handler = co.wrap(....{
   let restaurants = yield getRestaurants(...);


Or probably even worst:
let resp = yield dynamodb.scan(req).promise();
Yan Cui (73) [Avatar] Offline
#2
Now that Lambda supports Node8.1 you can use the async-await syntax. But the support was released halfway through the course, it was simply too much work required to redo all the demo sessions so it'll likely stay the way it is.

To convert from co.wrap functions to async-await is pretty straight forward, mostly a case of replacing a few keywords - `co.wrap(function* (x) ...)` with `async function (x) { ... }`, and replace `yield ...` with `await ...`.