Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail fast if no URL is provided #1765

Closed
ghost opened this issue Aug 28, 2018 · 1 comment
Closed

Fail fast if no URL is provided #1765

ghost opened this issue Aug 28, 2018 · 1 comment

Comments

@ghost
Copy link

ghost commented Aug 28, 2018

Summary

Making a request without URL (config.url being undefined, null or an empty string) is very likely bug in the application using axios. It would help finding these if axios could fail fast (before calling the adapter).

This behavior can only be implemented with request interceptors if it can be ensured that the interceptor containing the check

  • is the last one (because other request interceptors may set the URL)
  • is not removed before a request is being made.

I'd like to suggest adding the following code in https://github.com/axios/axios/blob/v0.18.0/lib/core/dispatchRequest.js#L57:

if (!config.url) {
  return Promise.reject(createError('Missing request URL', config));
}

Context

  • axios version: 0.17.1
  • Environment: any
@jasonsaayman
Copy link
Member

Closing in favour of #3110

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

No branches or pull requests

1 participant