79257646

Date: 2024-12-06 10:33:02
Score: 0.5
Natty:
Report link

Cannot use body and headers with GET method, Solution 1 - Instead of GET method you can make the method as POST or PUT to send body and headers.

Solution 2 - If you want to send data with GET method you can send it as queryParams

const userDetails = { name: "john", email: "[email protected]", password: "1234", }

    const queryParams = new URLSearchParams(userDetails).toString();

You can send queryParams in api url as

await fetch(`http://localhost:8001/user?${queryParams}`, {
      method: "GET",
    });

and receive it as req.query in backend

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Starts with a question (0.5): Cannot use
  • Low reputation (1):
Posted by: Abhi_Stacks