Hii, Everyone i’m actually creating a amazon price checker by watching a video on internet by " [Web Dev Simplified]" The code i written is not sending an email can anyone tell me where did i went wrong and why my code is not sending an email
require('dotenv').config()
const sgMail = require('@sendgrid/mail')
sgMail.setApiKey(process.env.SENDGRID_API_KEY)
const nightmare = require('nightmare')()
const arguments = process.argv.slice(2)
const url = arguments[0]
minPrice = arguments[1]
checkPrice()
async function checkPrice() {
const priceString = await nightmare.goto(url)
.wait("#priceblock_ourprice")
.evaluate(() => document.getElementById("priceblock_ourprice").innerText)
.end()
const priceNumber = parseFloat(priceString.replace('₹', ''))
if (priceNumber < minPrice) {
sendEmail(
'price is low',
`The price on ${url} has dropped to ${minPrice}`
)
}
}
function sendEmail(subject, body) {
const email = {
to: "lolanix291@fleeebay.com",
from: "Price-checker-project@example.com",
subject: subject,
text: body,
html: body
}
return sgMail.send(email)
}