diff --git a/lib/core/AxiosError.js b/lib/core/AxiosError.js index f28b8861..138d3194 100644 --- a/lib/core/AxiosError.js +++ b/lib/core/AxiosError.js @@ -5,7 +5,7 @@ import utils from '../utils.js'; class AxiosError extends Error { static from(error, code, config, request, response, customProps) { const axiosError = new AxiosError(error.message, code || error.code, config, request, response); - axiosError.cause = error; + Object.defineProperty(axiosError, 'cause', {value: error, configurable: true, writable: true}); axiosError.name = error.name; // Preserve status from the original error if not already set from response