I updated nuxtjs application version 3.2.0 to 3.4.3. now when a client call server api (which calling a backend server) i have this exception
[nitro] [dev] [uncaughtException] TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of Response 3:13:26 PM at new NodeError (node:internal/errors:372:5) at write_ (node:_http_outgoing:742:11) at ServerResponse.end (node:_http_outgoing:855:5) at Immediate. (file:///home/xxx/dev/projects/websites.modules/ae.loftoffices/node_modules/h3/dist/index.mjs:613:22) at processImmediate (node:internal/timers:466:21) { code: 'ERR_INVALID_ARG_TYPE' }
i dont understand what is the issue, here the api
export default defineEventHandler(async (event) => {
const {BACKEND_REST_API, ENQUIRY_TOKEN, ENQUIRY_PERSON_IN_CHARGE_EMAIL, COMPANY_UNID, ENQUIRY_TITLE, ENQUIRY_TYPE, ENQUIRY_SOURCE, } = useRuntimeConfig();
const form = await readBody(event);
console.log("url used for enquiry rest call :" + BACKEND_REST_API);
console.log("Enquiry token :" + ENQUIRY_TOKEN);
form.author = ENQUIRY_TITLE
form.personInChargeEmail = ENQUIRY_PERSON_IN_CHARGE_EMAIL;
form.contactPersonCompany = 'N/A';
form.companyUnid = COMPANY_UNID;
form.type = ENQUIRY_TYPE;
form.source = ENQUIRY_SOURCE;
delete form.bot;
console.log(form);
return await $fetch.raw(BACKEND_REST_API+"/enquiry/add", {
method: "POST",
body: form,
headers: {
Authorization: ENQUIRY_TOKEN,
},
})
})
and the client call
await useFetch("/api/enquiry", {
method: "POST",
body: values,
onResponse({request, response, options}) {
// Process the response data
if (response.status === 200) {
errorMessage.value = "";
successMessage.value = "Your message was sent successfully and will receive further emails from us soon. Thank you!";
}
},
onResponseError({request, response, options}) {
console.debug(response);
if (response.status === 400) {
successMessage.value = "";
errorMessage.value = "There may be an issue with our server. Please try again later, or send an email to info@loftoffices.ae";
} else {
successMessage.value = "";
errorMessage.value = "Sorry we couldn’t send the message, there may be an issue with our server. Please try again later, or send an email to ........"
}
},
});
any idea?