Update index.js
This commit is contained in:
parent
93985a6837
commit
e5ea735a3d
18
index.js
18
index.js
|
|
@ -166,7 +166,7 @@ async function scrapeWithCheerio(url) {
|
|||
return items;
|
||||
}
|
||||
|
||||
async function sendMail(subject, body, isError = false) {
|
||||
async function sendMail(subject, body) {
|
||||
try {
|
||||
await axios({
|
||||
url: process.env.API_DISTI_HOST + "/api/export/items-sold-out",
|
||||
|
|
@ -201,14 +201,12 @@ async function sendMail(subject, body, isError = false) {
|
|||
to: EMAILS.join(","),
|
||||
subject,
|
||||
text: body,
|
||||
attachments: isError
|
||||
? []
|
||||
: [
|
||||
{
|
||||
filename: fileName,
|
||||
content: response.data, // attach from memory
|
||||
},
|
||||
],
|
||||
attachments: [
|
||||
{
|
||||
filename: fileName,
|
||||
content: response.data, // attach from memory
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
await transporter.sendMail(mailOptions);
|
||||
|
|
@ -270,7 +268,7 @@ async function main() {
|
|||
|
||||
if (errors.length > 3) {
|
||||
const msg = errors.map((e) => `URL: ${e.url}\nMessage: ${e.message}`).join("\n\n");
|
||||
await sendMail("[New Items] - Scraping Sold Out Error Report", msg, true);
|
||||
await sendMail("[New Items] - Scraping Sold Out Error Report", msg);
|
||||
} else {
|
||||
const msg = inserted.map((i) => `Shop: ${i.name}\nSold: ${i.count} items`).join("\n\n");
|
||||
await sendMail("[New Items] - Scraping Sold Out Success", msg);
|
||||
|
|
|
|||
Loading…
Reference in New Issue