d-branch-2 (#18)
* ✨ refactor: streamline sitemap generation and contact form logic * ✨ refactor: update sendEmail function to handle JSON data
This commit is contained in:
@@ -1,17 +1,20 @@
|
||||
import {FormData} from "@/app/components/Contact";
|
||||
export function sendEmail(
|
||||
data: string,
|
||||
): Promise<{ success: boolean; message: string }> {
|
||||
const apiEndpoint = "/api/email";
|
||||
|
||||
export function sendEmail(data: FormData): Promise<{ success: boolean, message: string }> {
|
||||
const apiEndpoint = '/api/email';
|
||||
|
||||
return fetch(apiEndpoint, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
return fetch(apiEndpoint, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: data,
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((response) => {
|
||||
return { success: true, message: response.message };
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((response) => {
|
||||
return {success: true, message: response.message};
|
||||
})
|
||||
.catch((err) => {
|
||||
return {success: false, message: err.message};
|
||||
});
|
||||
}
|
||||
.catch((err) => {
|
||||
return { success: false, message: err.message };
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user