You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm attempting to identify if a query request I'm making is failing due to an access token expiring.
Actual outcome:
I'm receiving this error: Network error: Server response was missing for query 'undefined'.
Which does not contain the error.networkError.response.status I need to determine the actual response status returned from the fetchAPI
#1205 added the response to the error so that the status could be identified, but #1491 made it so that it would only add it if the response is missing a valid JSON body.
This means that any non-ok response status that contains a JSON body will throw an error that does not have the response or response.status returned from the fetch.
How to reproduce the issue:
it('should throw an error with the response body when request is forbidden', () => {
const unauthorizedUrlWithBody = 'http://unauthorized.test.with.body/';
const unauthorizedResponse = {
status: 403,
body: {message: 'Forbidden message'}
}
fetchMock.mock(unauthorizedUrlWithBody, unauthorizedResponse);
const unauthorizedInterface = createNetworkInterface({
uri: unauthorizedUrlWithBody,
});
return unauthorizedInterface.query(doomedToFail).catch(err => {
assert.isOk(err.response); // Fails here, err.response is undefined
assert.equal(err.response.status, unauthorizedResponse.status);
assert.equal(
err.message,
'Network request failed with status 403 - "Forbidden"',
);
});
});
Version
apollo-client@1.9.3
The text was updated successfully, but these errors were encountered:
This is merged for the latest branch and I will cut a release this week. I've added it to the 2.0 milestone to update apollo-link-http to handle this case as well. Thanks for the great work @lukeggchapman
I was coming across the same problem. On my case. it was a server response problem. solved that using "data" before the response.
So your response need to be like this from the server side: { data: { id, name, etc } }
Intended outcome:
I'm attempting to identify if a query request I'm making is failing due to an access token expiring.
Actual outcome:
I'm receiving this error:
Network error: Server response was missing for query 'undefined'.
Which does not contain the
error.networkError.response.status
I need to determine the actual response status returned from the fetchAPI#1205 added the response to the error so that the status could be identified, but #1491 made it so that it would only add it if the response is missing a valid JSON body.
This means that any non-ok response status that contains a JSON body will throw an error that does not have the response or response.status returned from the fetch.
How to reproduce the issue:
Version
The text was updated successfully, but these errors were encountered: