var jsonObj = JSON.stringify(obj); var header = new Headers(); header.append('Content-Type', 'application/json'); header.append('Accept', 'application/json'); var request = new Request(URL, { method: 'POST', mode: 'no-cors', body: jsonObj, headers: header }); fetch(request) .then( (responce) => { if (!responce.ok) { return Promise.reject(new Error( 'Responce failed: ' + responce.status + ' (' + responce.statusText + ')' )); } }) 

In IE, the header is sent as needed. But in Chrome and Firefox, when sending a request, the header becomes: "text / plain; charset = UTF-8". How to solve this problem?

  • no need to cut under harmful IE :) - ikerya
  • If you remove the mode: 'no-cors' , then the headlines are set as expected, but why so, until I understood it - andreymal
  • I also do not understand, so I ask :) I just have a server and a client on different ports localhost. The browser requires you to return the Access-Control-Allow-Origin header with the domain from which the client’s request comes or to enable the 'no-cors' mod. I connected this mod and a new problem appeared. - Uladzislau Radzko

0