@idearium/fetch
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -5,2 +5,8 @@ # @idearium/fetch | ||
### Fixed | ||
- Fixed error when no content-type header is returned. | ||
## v2.0.2 | ||
### Changed | ||
@@ -7,0 +13,0 @@ |
@@ -6,3 +6,7 @@ 'use strict'; | ||
const parseBody = (response) => { | ||
if (response.headers.get('Content-Type').includes('application/json')) { | ||
if ( | ||
response.headers && | ||
response.headers.get('Content-Type') && | ||
response.headers.get('Content-Type').includes('application/json') | ||
) { | ||
return response.json(); | ||
@@ -9,0 +13,0 @@ } |
{ | ||
"name": "@idearium/fetch", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "A package to make fetching trivial.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -131,1 +131,13 @@ 'use strict'; | ||
}); | ||
it('does not fail if no content header is returned', async () => { | ||
expect.assertions(1); | ||
fetchMock.get(testUrl, { status: 400 }); | ||
await expect(fetchApi(testUrl)).resolves.toMatchObject({ | ||
ok: false, | ||
result: {}, | ||
status: 400 | ||
}); | ||
}); |
4959
127