Closed oxsmose closed 5 months ago
Finally it works with the following code:
const data = {
title: title,
};
const formBody = new URLSearchParams(data).toString();
const response = await fetch("/api/layer", {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: formBody
});
And Json definitly not working.
Hi there 👋
I am glad you figured it out.
If you are just starting out building apps I would recommend looking into our Remix template. We believe it has a better developer experience and we have a lot more documentation for it.
The nodes backend receives empty body when data is sent with useAuthenticatedFetch POST query.
Part of the code in client:
Server side:
I tried on an other route than api to revert back to the Fetch js vanilla code. Same issue. I tried to use "body-parser" with no more success. I tried formData with "express.urlencoded({ extended: true })" with no more success.
Steps to reproduce the problem