Just return a json response
This commit is contained in:
@@ -15,27 +15,27 @@ export const POST = (async ({ request, fetch }) => {
|
||||
throw error(400, { message: 'INVALID_EMAIL' })
|
||||
}
|
||||
|
||||
// return json(email)
|
||||
return json(email)
|
||||
|
||||
// Newsletter API request
|
||||
const req = await fetch(`https://emailoctopus.com/api/1.6/lists/${NEWSLETTER_LIST_ID}/contacts`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
api_key: NEWSLETTER_API_TOKEN,
|
||||
email_address: email,
|
||||
})
|
||||
})
|
||||
const res = await req.json()
|
||||
console.log('server API response:', res)
|
||||
// const req = await fetch(`https://emailoctopus.com/api/1.6/lists/${NEWSLETTER_LIST_ID}/contacts`, {
|
||||
// method: 'POST',
|
||||
// headers: { 'Content-Type': 'application/json' },
|
||||
// body: JSON.stringify({
|
||||
// api_key: NEWSLETTER_API_TOKEN,
|
||||
// email_address: email,
|
||||
// })
|
||||
// })
|
||||
// const res = await req.json()
|
||||
// console.log('server API response:', res)
|
||||
|
||||
// Other error
|
||||
if (res && res.status !== 'PENDING') {
|
||||
throw error(400, { message: res.error.code })
|
||||
}
|
||||
// // Other error
|
||||
// if (res && res.status !== 'PENDING') {
|
||||
// throw error(400, { message: res.error.code })
|
||||
// }
|
||||
|
||||
return json({
|
||||
success: true,
|
||||
message: res.status,
|
||||
})
|
||||
// return json({
|
||||
// success: true,
|
||||
// message: res.status,
|
||||
// })
|
||||
}) satisfies RequestHandler
|
||||
Reference in New Issue
Block a user