mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -08:00
⚡ Improve axios output to be more identical to request (#2588)
This commit is contained in:
parent
aecb30dfa8
commit
416e15cdb6
|
@ -548,10 +548,15 @@ async function proxyRequestToAxios(
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.debug('Request proxied to Axios failed', { error });
|
Logger.debug('Request proxied to Axios failed', { error });
|
||||||
|
|
||||||
// Axios hydrates the original error with more data. We extract them.
|
// Axios hydrates the original error with more data. We extract them.
|
||||||
// https://github.com/axios/axios/blob/master/lib/core/enhanceError.js
|
// https://github.com/axios/axios/blob/master/lib/core/enhanceError.js
|
||||||
// Note: `code` is ignored as it's an expected part of the errorData.
|
// Note: `code` is ignored as it's an expected part of the errorData.
|
||||||
const { request, response, isAxiosError, toJSON, config, ...errorData } = error;
|
const { request, response, isAxiosError, toJSON, config, ...errorData } = error;
|
||||||
|
if (response) {
|
||||||
|
error.message = `${response.status as number} - ${JSON.stringify(response.data)}`;
|
||||||
|
}
|
||||||
|
|
||||||
error.cause = errorData;
|
error.cause = errorData;
|
||||||
error.error = error.response?.data || errorData;
|
error.error = error.response?.data || errorData;
|
||||||
error.statusCode = error.response?.status;
|
error.statusCode = error.response?.status;
|
||||||
|
|
Loading…
Reference in a new issue