未验证 提交 6fca6a70 编写于 作者: B Black-Hole 提交者: GitHub

refactor(helpers): optimize the logic of isAxiosError (#3546)

1. add the judgment of null
Co-authored-by: NJay <jasonsaayman@gmail.com>
上级 476ee884
'use strict';
var utils = require('./../utils');
/**
* Determines whether the payload is an error thrown by Axios
*
......@@ -7,5 +9,5 @@
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
*/
module.exports = function isAxiosError(payload) {
return (typeof payload === 'object') && (payload.isAxiosError === true);
return utils.isObject(payload) && (payload.isAxiosError === true);
};
......@@ -17,4 +17,9 @@ describe('helpers::isAxiosError', function () {
expect(isAxiosError(new Error('Boom!')))
.toBe(false);
});
it('should return false if the error is null', function () {
expect(isAxiosError(null))
.toBe(false);
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册