Skip to content

Commit

Permalink
fix: error access error
Browse files Browse the repository at this point in the history
If data.errors did not exist, we would get TypeError: Cannot read
property '0' of undefined error.
  • Loading branch information
moltar committed Jun 7, 2021
1 parent 0b41a8a commit 404a333
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/helpers/api-error-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ export function apiErrorFactory<T extends ModelErrorContainer>(
error: AxiosError<T>,
): ExtendableError {
const { response } = error

if (response) {
const { headers, data } = response
const modelError: ModelError | undefined = data.errors[0]

const modelError: ModelError | undefined = data?.errors?.shift()

if (modelError === undefined) {
return new SellingPartnerUnknownError(
{
Expand Down

0 comments on commit 404a333

Please sign in to comment.