2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-11 18:02:32 +03:00

fix(fetch): treat fetch-related TypeError as an AxiosError.ERR_NETWORK error; (#6380)

This commit is contained in:
Dmitriy Mozgovoy
2024-05-07 21:26:46 +03:00
committed by GitHub
parent 81e0455b7b
commit bb5f9a5ab7
2 changed files with 18 additions and 5 deletions
+10
View File
@@ -370,4 +370,14 @@ describe('supports fetch with nodejs', function () {
assert.strictEqual(data, '/?test=1&foo=1&bar=2');
});
it('should handle fetch failed error as an AxiosError with ERR_NETWORK code', async () => {
try{
await fetchAxios('http://notExistsUrl.in.nowhere');
assert.fail('should fail');
} catch (err) {
assert.strictEqual(String(err), 'AxiosError: Network Error');
assert.strictEqual(err.cause && err.cause.code, 'ENOTFOUND');
}
});
});