Skip to content

Conversation

@devinpitcher
Copy link

Fixes #168

Adds the request object to the error. This is important and follows the way that Axios handles errors.

error.isAxiosError = true;
error.config = config;
error.request = {
responseUrl: config.url,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be responseURL and not responseUrl. I least in my browser URL is uppercased. (see #287)

@marcbachmann
Copy link
Collaborator

marcbachmann commented Aug 4, 2024

I don't think there's an easy way to support that correctly.
error.request is the original outgoing request based on the adapter implementation.

require('axios').get('https://example.com/foo').catch((err) => console.error(err.request.url))
> undefined

require('axios').get('https://example.com/foo').catch((err) => console.error(err.request.responseURL))
> undefined

require('axios').get('https://example.com/foo').catch((err) => console.error(err.request.responseUrl))
> undefined

require('axios').get('https://example.com/foo', {adapter: 'fetch'}).catch((err) => console.error(err.request.url))
> 'https://example.com/foo'

responseUrl or responseURL both don't exist at least on node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

networkError method should define a request attribute in mocked error response

3 participants