So I have this question but I cant find a solution. I am scraping my website with axios and cheerio and my url's are very big so I want to use a shortener, I found npm (node-url-shortener) and its very simple to use shortUrl.short('https://google.com', function(err, url){
console.log(url);
});
but I dont want to console.log I want to store that value
$(
".searchListing"
).each((index, element) => {
const name = $(element)
.children(".media")
.children("a")
.text();
let url = $(element)
.children(".media")
.children("a")
.attr("href");
shortUrl.short(url, function(err, url) {
return url;
});
console.log(??????);
prices[index] = { name, url };
});
How can I store the shortened url in my array outside of shortUrl.short
module?