POST request fails to send body to backend API
Answered
Ichneumonid wasp posted this in #help-forum
Ichneumonid waspOP
My Next.js (with the app router) fails to send body data in a POST request back to my Express API. Postman is successfully able to submit data, but Next.js fails to pass data through. The screenshot is the API route that is being called-- you can see that data from my client form to the Next.js API is sent, but my backend fails to receive the data. Is there something wrong with my code (such as my headers) that prevents data from being passed through?
6 Replies
set content type to application/json
Answer
Ichneumonid waspOP
@Yi Lon Ma thanks! however I plan to send some base64 data through, hence why I utilized multipart/form-data. would that still be fine in an application/json setting?
right now you're doing
request.json()
which returns a json string so you need application/jsonIchneumonid waspOP
ohhhh
yeah that didn't click in my head. thanks for the help!