Return Value From An Async Function
How can I return the value from an async function? I've the following Promise: function reqGitActivity (url) { const options = { url: url, headers: { 'User-Agent':
Solution 1:
It looks like you can only access that value inside of a callback.
So, instead of console.log(JSON.parse(githubActivity()))
, use:
githubActivity().then( body => console.log( JSON.parse( body ) ) )
Post a Comment for "Return Value From An Async Function"