I'm attempting to use scrape-it as a dependency that I downloaded from NPM earlier today. I'm able to get the content back that I want, but need to store the results in a variable rather than handle them via the callback.
Using the 'sample' from scrape-it docs, when I try the following:
var myVar = scrapeIt("http://ionicabizau.net", {
title: ".header h1"
, desc: ".header h2"
, avatar: {
selector: ".header img"
, attr: "src"
}
}).then(page => {
return page;
});
console.log(myVar);
I get the result: Promise { <pending> }
I've also tried using 'await' prior to calling the scrapeIt() function, but when I do that locally 'Unexpected identifier' syntax error in return.
Mind you, when I've tried this on the RunKit + npm site, it does work there, but it doesn't work for me locally. I've uninstalled and reinstalled the package, and it seems like I have all the necessary dependencies, so not sure what I'm doing wrong. :-\
While this obviously does touch on the asynchronous nature of javascript, the focal point of the question is to better understand interaction with promises.