stevenjr1988
stevenjr1988
CDCloudflare Developers
Created by stevenjr1988 on 2/28/2024 in #workers-help
Email worker, with fetch, sending to API
I am trying to set up a catch-all email, and send all incoming emails to a worker. The work is to send the email to my API. the API will then handle the rest. Right now, I am getting rejected emails that the address dose not exist. While editing the worker, I noticed "Error: No fetch handler!"
export default {
async email(message, env, ctx) {
const response = await fetch('https://api.domain.tld', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({email:message}),
});
if (!response.ok) {}
const data = await response.json();
}
}
export default {
async email(message, env, ctx) {
const response = await fetch('https://api.domain.tld', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({email:message}),
});
if (!response.ok) {}
const data = await response.json();
}
}
4 replies