Tuesday, 2 May 2017

Fetch response malformed

The issue is basically that the fetch response object is not correct. Pictures to clarify the issue are below as it is hard to explain.

My fetch request code.

fetch(this.constructUrl(url), {
        method: method,
        mode: 'no-cors',
        headers: new Headers({
            'Authorization': 'Bearer ' + this.token,
            'Accept': 'application/json',
            'Content-Type': 'application/json',
        }),
        body: new FormData(document.getElementById(formIdentifier))
    }).then(function (response) {
        if (response.ok) {
            return response.json().then(callback);
        }
        console.log(response);
    }).catch(function(error) {
        console.log(error);
    });

The fetch response object. Fetch response object image

The chrome response/request details Chrome request details

The chrome response data Chrome response data

So as you can see, the data in chrome looks correct but for some reason, the fetch response object does not seem to reflect what chrome picks up.



via Francis Malloch

No comments:

Post a Comment