I want to send push notification with http request and then call process.exit() function but it doesn't work, process stops but push notification doesn't send. It works if i remove the process.exit function. Here is the code:
await page
.waitForSelector(".guest", { timeout: 5000 })
.then(async () => {
console.log("Not logged in, exiting");
await pushNotification("App has stopped, probably session expired.");
process.exit();
})
async function pushNotification(msg) {
var options = {
method: "POST",
url: "url",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
to: "",
title: "",
body: ``,
}),
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
}