Fix "Cannot read ... of undefined" from Axios response (#4541)

# What this PR does
Fix "Cannot read ... of undefined" from Axios response



<!--
*Note*: if you have more than one GitHub issue that this PR closes, be
sure to preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
This commit is contained in:
Dominik Broj 2024-06-17 09:47:56 +02:00 committed by GitHub
parent 6bb9fcef4c
commit 8f64a44e54
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -105,19 +105,19 @@ class BaseFaroHelper {
this.faro?.api.pushEvent(name, {
url: res?.config?.url,
status: `${res?.status}`,
statusText: `${res.statusText}`,
method: res.config?.method.toUpperCase(),
statusText: `${res?.statusText}`,
method: res?.config?.method.toUpperCase(),
});
};
pushAxiosNetworkError = (res: AxiosResponse) => {
this.faro?.api.pushError(new Error(`Network error: ${res.status}`), {
pushAxiosNetworkError = (res?: AxiosResponse) => {
this.faro?.api.pushError(new Error(`Network error: ${res?.status}`), {
context: {
url: res.config?.url,
url: res?.config?.url,
type: 'network',
data: `${safeJSONStringify(res.data)}`,
status: `${res.status}`,
statusText: `${res.statusText}`,
status: `${res?.status}`,
statusText: `${res?.statusText}`,
timestamp: new Date().toUTCString(),
},
});