Unnecessary double await’s

In M220JS, test/lessons/basic-updates.spec.js, lines 124 and 145 - toArray() returns an array and not a Promise. So, there’s no need to use another await, or am I missing something?

More, unnecessary double await’s in src/dao/moviesDAO.js lines 208 and 209.

those are just files connected to a particular lesson. These should be used as a reference on how certain things in that particular lesson is done. These are not your assignment finals.

Thanks for pointing that out @hotdog1987, knew that already. :slight_smile:

It’s been mentioned before.

There are a lot more than just those, and there are also quite a number of general conventions that should not be used. i.e Date.parse()and String(e) just to name a couple.

There is an eslint packaged in the dependencies as well as an .eslint config, which I believe can be improved to pick up such errors as return await and similar bad practice parts

http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#toArray
http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#toArray

It returns a promise of an array

@nathan.leniz You missed the point.

I’m being lazy because that’s just actually the very first google result ( and Jake works for google…, conspiracy! )

Summarizes “all the things” but basically scroll to the bottom:

Note: Outside of try/catch blocks, return await is redundant. There’s even an ESLint rule to detect it, but it allows it in try/catch.

That is what we are saying the code examples here ( actually also in the DAO as well as the lesson examples ) does incorrectly on several occasions.