Create a scrapingbee url when using the fallback

Javascript hoists variables to the top of scope, so `url` here
refers to the `url` variable defined lower in the block.
This commit is contained in:
Jackson Harper
2022-07-05 08:41:30 -07:00
parent 2231d6fc9b
commit 9554f8f6ba

View File

@ -358,18 +358,18 @@ async function fetchContent(req, res) {
// fallback to scrapingbee
const sbResult = await fetchContentWithScrapingBee(url);
const url = finalUrl || sbResult.url;
const sbUrl = finalUrl || sbResult.url;
const content = sbResult.domContent;
logRecord.fetchContentTime = Date.now() - functionStartTime;
const apiResponse = await sendCreateArticleMutation(userId, {
url,
url: sbUrl,
articleSavingRequestId,
preparedDocument: {
document: content,
pageInfo: {
title: sbResult.title,
canonicalUrl: url,
canonicalUrl: sbUrl,
},
},
skipParsing: !content,