Good point re. simply returning a promise being the same here, thanks! I just pasted from a Lambda I was writing where I had a try/catch block and was returning some messages, so I needed the await before and didn't even think about removing it. E.g.:
awaitclient.put(params).promise();return{message:"Success! The headlines were: "+topHeadlines}
Re. splitting the function that's a good idea, thanks. This was a copy/paste from a quick and dirty Lambda function for a personal project, but I like how your promise chain rewrite is both easier to read and more testable. Will think twice next time instead of lazily reaching for my async/await 💪
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Good point re. simply returning a promise being the same here, thanks! I just pasted from a Lambda I was writing where I had a try/catch block and was returning some messages, so I needed the await before and didn't even think about removing it. E.g.:
Re. splitting the function that's a good idea, thanks. This was a copy/paste from a quick and dirty Lambda function for a personal project, but I like how your promise chain rewrite is both easier to read and more testable. Will think twice next time instead of lazily reaching for my async/await 💪