Skip to content

Commit e624733

Browse files
Jon Wrightdevelopit
andauthored
fix: updates error handling to match axios (#56)
Co-authored-by: Jason Miller <[email protected]>
1 parent 95a68f3 commit e624733

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ export default (function create(/** @type {Options} */ defaults) {
203203
}
204204

205205
const ok = options.validateStatus ? options.validateStatus(res.status) : res.ok;
206-
if (!ok) return Promise.reject(response);
207206

208207
if (options.responseType == 'stream') {
209208
response.data = res.body;
@@ -217,7 +216,7 @@ export default (function create(/** @type {Options} */ defaults) {
217216
response.data = JSON.parse(data);
218217
})
219218
.catch(Object)
220-
.then(() => response);
219+
.then(() => (ok ? response : Promise.reject(response)));
221220
});
222221
}
223222

0 commit comments

Comments
 (0)