-
-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Description
Describe the bug
When using the request()
method on an instance, the request throws an error if the instance's config has url
specified, but not baseUrl
.
Error indicates a missing url
arg:
The "url" argument must be of type string. Received type undefined
This contradicts the documentation, which states that
Only the
url
is required.
and
baseURL
will be prepended tourl
unlessurl
is absolute.
To Reproduce
Code snippet to reproduce, ideally that will work by pasting into something like https://npm.runkit.com/axios, a hosted solution, or a repository that illustrates the issue. If your problem is not reproducible, please file under Support or Usage Question
var axios = require("axios")
// this works
axios.create({ baseURL: 'https://www.google.com/' })
.request()
.then(response => console.log(`response status: ${response.status}`))
.catch(err => console.log(err));
// this errors
axios.create({ url: 'https://www.google.com/' })
.request()
.then(response => console.log(`response status: ${response.status}`))
.catch(err => console.log(err));
Expected behavior
The request should use the url
property if present and absolute. Alternatively, the documentation should reflect that baseUrl
is required to use instance.request()
.
Environment:
- Axios Version: 0.19.0
- OS: Windows 10 Pro 1803
- Browser: Chrome 74.0.3729.169 64-bit