Skip to content

Fail fast if no URL is provided #1765

@ghost

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions