I am sending a POST request using useSubmit
hook for it but it seems that the header that I define is not taken in consideration.
Here is my submit:
submit('/dashboard/', {
method: 'post',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ some: "values" }),
});
Here is my action function:
export async function action({ request }) {
console.log('request: ', request);
const data = await request.json();
return "uhuu";
}
And here is the log of the request received on the action function. Observe on the header the content-type
Observe that it is not what I defined on
submit('/dashboard/', {
method: 'post',
headers: {
'Content-Type': 'application/json',
},
I’m running it from localhost:3000
Using Postman it worked fine the problem is when I try to use the useSubmit
on the code, the "Content-Type"
on the header changed correctly to 'Content-Type': 'application/json'
.