1

I'm trying post request by my react app and I have return status 415. I tested this endpoint by postman exactly which I got from this console.log(JSON.stringify(data.data)); and all is right. I notice that my request haven't the same content-type which I set in fetch method.

    fetch("http://localhost:8080/v1/useranswers", {
      method: "POST",
      mode: "no-cors",
      headers: {
        Accept: " */*",
        "Content-Type": "application/json",
      },
      body: JSON.stringify(data.data),
    }).then(function (response) {
      return response;
    });

enter image description here

xaos
  • 21
  • 1
  • you have to show useranswers API header code – Serge Jul 03 '22 at 15:44
  • Use the postman code generator then. Its on the right-side panel. Just copy the fetch method from the generator – Toumash Jul 03 '22 at 16:18
  • Toumash I copy method from postman but I must add one line mode: "no-cors", and with this problem remains unchanged – xaos Jul 03 '22 at 16:52

1 Answers1

0

I add line @CrossOrigin(origins = "*") in my controller and all is right :)

xaos
  • 21
  • 1