When use fetch for request in server using headers return
SyntaxError: Unexpected end of input at index.js:50 at <anonymous> Line of code 50 is }).then(res => res.json())
What can be wrong?
This code fetch.
fetch(api-url, { mode: 'no-cors', method: "POST", headers: { 'Accept': 'application/json', 'Content-Type': ' application/json', 'X-API-SERVER': '85499f9f' }, }).then(res => res.json()) .then(res => { if (res.status === 200){ console.log("accepted"); }else { console.log(res.error); } console.log(res.error) }).catch(err => console.log(err))
fetchresponse is successful, are you setting theresultstate to the given response?