react-native-simple-networking
Advanced tools
Comparing version
@@ -140,3 +140,3 @@ "use strict"; | ||
async function logAxiosError(error) { | ||
var _a, _b, _c, _d; | ||
var _a, _b, _c, _d, _e; | ||
if (!axios_1.default.isAxiosError(error)) { | ||
@@ -160,7 +160,13 @@ console.log("Non axios error: "); | ||
report.request.data = shortenData(error.config.data); | ||
report.response = { | ||
data: JSON.parse(shortenData(typeof ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) == 'string' ? JSON.parse(error.response.data) : (_b = error.response) === null || _b === void 0 ? void 0 : _b.data)), | ||
headers: (_c = error.response) === null || _c === void 0 ? void 0 : _c.headers, | ||
code: (_d = error.response) === null || _d === void 0 ? void 0 : _d.status | ||
}; | ||
try { | ||
report.response = { | ||
data: JSON.parse(shortenData(typeof ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) == 'string' ? JSON.parse(error.response.data) : (_b = error.response) === null || _b === void 0 ? void 0 : _b.data)), | ||
headers: (_c = error.response) === null || _c === void 0 ? void 0 : _c.headers, | ||
code: (_d = error.response) === null || _d === void 0 ? void 0 : _d.status | ||
}; | ||
} | ||
catch (e) { | ||
console.log("Networking Error Handler - Couldn't parse json for response report, raw data is "); | ||
console.log((_e = error.response) === null || _e === void 0 ? void 0 : _e.data); | ||
} | ||
// For easier copy / pasting | ||
@@ -167,0 +173,0 @@ console.log("Axios Error Report:"); |
{ | ||
"name": "react-native-simple-networking", | ||
"version": "1.0.59", | ||
"version": "1.0.60", | ||
"description": "This is a package that implements authentication state using zustand tied to axios interceptors in order to automatically add an 'authorization' header to all requests any time a request is sent with the created axios client. It also provides some basic request logging. The package will attempt to refresh any time an access token is expired, stalling all requests any time a token refresh is going on. ", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -181,7 +181,13 @@ import axios, { AxiosError, AxiosRequestConfig } from "axios"; | ||
report.request.data = shortenData(error.config.data); | ||
report.response = { | ||
data: JSON.parse(shortenData(typeof error.response?.data=='string'?JSON.parse(error.response.data):error.response?.data)), | ||
headers: error.response?.headers, | ||
code: error.response?.status | ||
try { | ||
report.response = { | ||
data: JSON.parse(shortenData(typeof error.response?.data=='string'?JSON.parse(error.response.data):error.response?.data)), | ||
headers: error.response?.headers, | ||
code: error.response?.status | ||
} | ||
} catch (e) { | ||
console.log("Networking Error Handler - Couldn't parse json for response report, raw data is ") | ||
console.log(error.response?.data) | ||
} | ||
// For easier copy / pasting | ||
@@ -188,0 +194,0 @@ console.log("Axios Error Report:") |
39164
1.31%948
1.17%