I would like to return not only the result of this Promise but also the iterable, the url
, with which it was a called. urls
is an array of urls.
function findMainLink(urls) {
return Promise.all(urls.map((url) => {
var result = nightmare
.goto(url)
.wait('#main')
.evaluate(function() {
return document.querySelector('#main a').href;
});
nightmare.end()
return result
}
}
vo(findMainLink)([
'https://yahoo.com',
'https://google.com'
])
.then(res => console.log(res))
.catch(e => console.error(e))
when I do return {result,url}
it does not resolve but instead gives me back the current status of the promise. How would I include the url in the result?