0

I am using Axios to get data from a url. When the url begins with http:// or https:// i get an error

Error: getaddrinfo ENOTFOUND <url> at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:50:26)

After researching i found that removing the http:// and https:// prefixes could fix this. But the problem is that Axios automatically includes these prefixes.

I'm wondering if anyone knows how to manually set the baseUrl like something below.

 {
  host: 'dropbox.com',
  path: '/s/ioedmud5dbc2bnu/1100.%20mobi.jpg?dl=1'
}
1
  • it's not clear actually what you want exactly Commented Sep 11, 2018 at 14:09

1 Answer 1

2

From the Axios docs, you can create a new instance of axios with a custom config.

const instance = axios.create({
  baseURL: 'dropbox.com'
});

You can then use that instance to make a request:

instance.get('/s/ioedmud5dbc2bnu/1100.%20mobi.jpg?dl=1').then(...).catch(...);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.