How to get NextResponse body when using fetch api
Answered
Red-necked Grebe posted this in #help-forum
Original message was deleted.
Answered by Pacific herring
in return NextResponse.json({message: "message you want to pass", status: 200});
17 Replies
Pacific herring
@Red-necked Grebe
show full code
btw
in the route
you return a response
return NextResponse.json({message: "nothing happened", status: 204});
then in your component you await for it
const result = await res.json();
result.message will return "nothing happened"
it told you
that some data is not a valid json
because you're awaiting for a json
you telling it that it will receive a json
its like you expect me to talk to you in english but then my next message will be in italian
i'd change all your responses
Pacific herring
in return NextResponse.json({message: "message you want to pass", status: 200});
Answer
Pacific herring