How can someone fix this sending subject to discord webhook!

can someone help me fix

export default {
async email(message, env, ctx) {
switch (message.from) {
case "noreply@accounts.tiktok.com":
const webhookUrl = 'discord.com/api/webhooks/124790903927/webhookstuff'

try {
const response = await fetch(webhookUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
content: message.headers.get('Subject')
})
});

// Handle the response if needed (e.g., check for success)

} catch (error) {
console.error("Error sending webhook:", error);
// Optionally, handle the error gracefully (e.g., retry or notify)
}

break; // Important to keep this break statement

default:
message.setReject("Unknown address");
}
}
}
Was this page helpful?