In my ember app I'm using native Javascript fetch
-method (after user clicks login at login-form) to request a POST to a server-endpoint.
//...
const options = {
body,
headers,
method: 'POST'
};
return new RSVP.Promise((resolve, reject) => {
fetch(url, options).then((response) => {
response.text().then((text) => {
try {
let json = JSON.parse(text);
if (!response.ok) {
response.responseJSON = json;
reject(response);
} else {
resolve(json);
}
} catch (SyntaxError) {
response.responseText = text;
reject(response);
}
});
}).catch(reject);
});
//...
If the ember-app is loaded freshly, the first login-click results in an error. The reason seems to be, that the HTTP-Version is undefined at the error-requests. See: ember-server output:
If the app is not loaded freshly, fetch works as expected: ember-server output:
What could be the reason that the http-version is undefined? How I can set the HTTP-Version?
Aucun commentaire:
Enregistrer un commentaire