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

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

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.