mirror of
https://github.com/tenrok/axios.git
synced 2026-06-17 19:21:29 +03:00
fix(core): add the missed implementation of AxiosError#status property; (#6573)
This commit is contained in:
@@ -27,7 +27,10 @@ function AxiosError(message, code, config, request, response) {
|
|||||||
code && (this.code = code);
|
code && (this.code = code);
|
||||||
config && (this.config = config);
|
config && (this.config = config);
|
||||||
request && (this.request = request);
|
request && (this.request = request);
|
||||||
response && (this.response = response);
|
if (response) {
|
||||||
|
this.response = response;
|
||||||
|
this.status = response.status ? response.status : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.inherits(AxiosError, Error, {
|
utils.inherits(AxiosError, Error, {
|
||||||
@@ -47,7 +50,7 @@ utils.inherits(AxiosError, Error, {
|
|||||||
// Axios
|
// Axios
|
||||||
config: utils.toJSONObject(this.config),
|
config: utils.toJSONObject(this.config),
|
||||||
code: this.code,
|
code: this.code,
|
||||||
status: this.response && this.response.status ? this.response.status : null
|
status: this.status
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -48,4 +48,9 @@ describe('core::AxiosError', function() {
|
|||||||
expect(AxiosError.from(error, 'ESOMETHING', { foo: 'bar' }) instanceof AxiosError).toBeTruthy();
|
expect(AxiosError.from(error, 'ESOMETHING', { foo: 'bar' }) instanceof AxiosError).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should have status property when response was passed to the constructor', () => {
|
||||||
|
const err = new AxiosError('test', 'foo', {}, {}, {status: 400});
|
||||||
|
expect(err.status).toBe(400);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user