Api fetch throws on undefined `error.response`
Opened this issue · 0 comments
pnodet commented
Current version in package.json
:
"mangopay2-nodejs-sdk": "1.43.1",
Error message in production:
/app/node_modules/.pnpm/mangopay2-nodejs-sdk@1.43.1/node_modules/mangopay2-nodejs-sdk/lib/api.js:209
_.extend(error.response, {body: error.response.data}) : error.response.data;
^
TypeError: Cannot read properties of undefined (reading 'data')
at /app/node_modules/.pnpm/mangopay2-nodejs-sdk@1.43.1/node_modules/mangopay2-nodejs-sdk/lib/api.js:209:96
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Stack trace points to line 209, in my local dev environnement it seems to be line 217 :
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
.catch(function (error) {
if (error.code === "ERR_CANCELED" && abortSignal.aborted) {
var err = {
Message: "Request timed out",
Code: 408
};
self.errorHandler(err.Message, err);
reject(err);
} else {
var resolveArgument = (resolveWithFullResponse) ?
_.extend(error.response, {body: error.response.data}) : error.response.data;
if (_.isFunction(callback)) {
callback(resolveArgument, error.response);
}
self.errorHandler(error.message, error.response.data);
reject(resolveArgument);
}
});