Monday 23 April 2018

How to wrap a callback function with async/await?

I need to use a function from an 'old' module that uses callbacks. It's something like this:async function myWrapper(dataToParse) { myOldfunction(dataToParse, (err, parsedResult) => { if (err) { throw err; } console.log(parsedResult); }); } I need to modify this, so that instead of logging the result to the console, the parsedResult received by the callback becomes the return value of the wrapper.I've got no idea how to do it, can I get some help?

Submitted April 23, 2018 at 02:34PM by kace91

No comments:

Post a Comment