Javascript 返回节点模块外部的值
所以我有这个问题,但我找不到解决办法。我正在用axios和cheerio清理我的网站,我的url非常大,所以我想使用一个缩写器,我找到了npm(节点url缩写器),它使用起来非常简单Javascript 返回节点模块外部的值,javascript,node.js,axios,cheerio,url-shortener,Javascript,Node.js,Axios,Cheerio,Url Shortener,所以我有这个问题,但我找不到解决办法。我正在用axios和cheerio清理我的网站,我的url非常大,所以我想使用一个缩写器,我找到了npm(节点url缩写器),它使用起来非常简单shortUrl.short()https://google.com,函数(错误,url){ console.log(url); }); 但是我不想console.log我想存储该值 $( ".searchListing" ).each((index, element) => { con
shortUrl.short()https://google.com,函数(错误,url){
console.log(url);
});代码>
但是我不想console.log我想存储该值
$(
".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 };
});
如何在shortUrl.short
模块之外的数组中存储缩短的url?这是否回答了您的问题?这回答了你的问题吗?