When the variable response
is undefined, attempting to retrieve its property status
will result in an error:
Error: Unable to access property 'status' of undefined
const {
response,
response: { status },
request,
config,
} = error as AxiosError
Even assigning a default value to status
does not prevent this error. The issue still occurs with response
.
For example:
response: { status = 420 },
Is there a safe way to destructure this object? Appreciate any help.