-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Implement ok
boolean
response field
#858
Comments
ok is set automatically whenever you send a response with a status from 200-299:
|
I still do not get it, here are couple of examples with latest
{
[Symbol(realm)]: { settingsObject: {} },
[Symbol(state)]: {
aborted: false,
rangeRequested: false,
timingAllowPassed: false,
requestIncludesCredentials: false,
type: 'default',
status: 200,
timingInfo: null,
cacheState: '',
statusText: 'OK',
headersList: HeadersList {
cookies: null,
[Symbol(headers map)]: [Map],
[Symbol(headers map sorted)]: null
},
urlList: [],
body: {
stream: undefined,
source: '{"body":"Some invalid json","statusText":"DDDDD"}',
length: 49
}
},
[Symbol(headers)]: HeadersList {
cookies: null,
[Symbol(headers map)]: Map(2) { 'content-length' => [Object], 'content-type' => [Object] },
[Symbol(headers map sorted)]: null
}
}
{
[Symbol(realm)]: { settingsObject: {} },
[Symbol(state)]: {
aborted: false,
rangeRequested: false,
timingAllowPassed: false,
requestIncludesCredentials: false,
type: 'default',
status: 550,
timingInfo: null,
cacheState: '',
statusText: '',
headersList: HeadersList {
cookies: null,
[Symbol(headers map)]: [Map],
[Symbol(headers map sorted)]: null
},
urlList: []
},
[Symbol(headers)]: HeadersList {
cookies: null,
[Symbol(headers map)]: Map(1) { 'content-length' => [Object] },
[Symbol(headers map sorted)]: null
}
} I do not see any const response: Response = await fetch(url, requestInit);
if (!response.ok) {
console.log(response.statusText);
} |
Can you tell me a bit more about your setup please, node version, or is this in a browser?, and any libraries you are using as part of your fetching. The sample you've logged out doesn't look like a native fetch Response, which is what fetch-mock creates. |
I have node v20.11.0. I'm using |
It does, but it uses the native fetch classes to do so, so you should receive a genuine I'm happy to investigate further, but I'll need you to create a repo with a reduced test case in it so I can reproduce locally |
Thank you for clarification, and great project! I'll try to find out myself and will back here if find something interesting. |
I'm not sure, but I can't find a way to produce
ok
boolean
value in response object. https://developer.mozilla.org/en-US/docs/Web/API/Response/okThe text was updated successfully, but these errors were encountered: