Closed AllenFang closed 6 years ago
@AllenFang I came across this fix because I'm running into this error when trying to run tests on code that makes use of finally
.
TypeError: fetch(...).then(...).then(...).catch(...).finally is not a function
Code in question:
fetch(myUrl)
.then(response => {
if (response.status === 200) {
return response.json()
}
throw new Error('request failed.');
})
.then(({ data }) => doStuff(data))
.catch(e => { setError(e.message) })
.finally(() => doOtherStuff());
The test makes use of the following fetch mocking function:
fetchMock.mockResponseOnce(JSON.stringify(myResponseBody));
Does anyone know why I'd still be seeing this error given the fix in this PR?
Fix #54
@jefflau