mercredi 30 septembre 2020

POST works in Postman but not in browser ember

The frontend is using Ember and the backend uses Springboot (using maven to build). When I use postman to test the endpoints, everything works. But when I try to send the request using my code, it doenst send a request.

This is the code in my Ember app. I also tried ember-cli-cors already.

@action async myfunction() {
const payload = {
    "colour": "pink",
    "height": "tall",
    "sport": "hockey"
};

const url = 'my backend url';
let response = await fetch(url, {
    method: 'POST',
    headers: {
        'Content-Type': 'application/vnd.api+json'
    },
    body.payload
    });
  let json = await response.json();
  return;
 }
}



Aucun commentaire:

Enregistrer un commentaire