hey. how to return the result?
If inside the block, there will be an error
I can't do it.
return a value outside the function
const parser = async (req, res) => {
try {
const { service, url } = req.query;
if (service, url === undefined) return res.status(400).json({ undefined: 'check_fields' })
if (regservice == 'de') {
let ad = await axios.get(url),
$ = cheerio.load(ad.data);
let listItemsph = $(".card-slider ul li");
listItemsph.each(function(idx, li) {
const info = {
title: $("#item-detail-title").text().trim(),
price: $(".card-product-detail-price").text().trim(),
photo: {
ph: $(li).find('img').attr('src')
}
};
// return info
})
res.status(200).json(info)
}
}catch (err) {
console.log(err);
res.send("err")
}
}