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
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
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
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
Pacific herring
in return NextResponse.json({message: "message you want to pass", status: 200});
Answer
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
Pacific herring
![Image](https://cdn.discordapp.com/attachments/1164670399863328890/1164672507501097100/image.png?ex=654410cc&is=65319bcc&hm=6a13cab9231f5f19f3817ed8b5a54d8c247281dc0d0178932176fb7e67695601&)