add more logs
This commit is contained in:
@@ -17,18 +17,24 @@ async function sendEmailToUnsend(emailData: any, apiKey: string) {
|
|||||||
const url = new URL(apiEndpoint, UNSEND_BASE_URL); // Combine base URL with endpoint
|
const url = new URL(apiEndpoint, UNSEND_BASE_URL); // Combine base URL with endpoint
|
||||||
console.log("Sending email to Unsend API at:", url.href); // Debug statement
|
console.log("Sending email to Unsend API at:", url.href); // Debug statement
|
||||||
|
|
||||||
|
const emailDataText = JSON.stringify(emailData);
|
||||||
|
|
||||||
const response = await fetch(url.href, {
|
const response = await fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${apiKey}`,
|
Authorization: `Bearer ${apiKey}`,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify(emailData),
|
body: emailDataText,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const errorData = await response.text();
|
const errorData = await response.text();
|
||||||
console.error("Unsend API error response:", errorData);
|
console.error(
|
||||||
|
"Unsend API error response: error:",
|
||||||
|
errorData,
|
||||||
|
`\nemail data: ${emailDataText}`
|
||||||
|
);
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Failed to send email: ${errorData || "Unknown error from server"}`
|
`Failed to send email: ${errorData || "Unknown error from server"}`
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user