3rdsty4bl00d
3rdsty4bl00d

Reputation: 134

How can I set two baseURL using axios?

I am currently working on project that requires calling two api's. But, how do I set 2 baseURL.

In my main.jsfile

import axios from 'axios'

axios.defaults.baseURL = 'http://192.168.1.75/api'

axios.defaults.baseURL = 'http://192.168.14.66/api'

Upvotes: 1

Views: 145

Answers (1)

Saurav
Saurav

Reputation: 84

Use prototype method in main.js file as below:

const authInstance =  axios.create({ baseURL: 'http://192.168.1.75/api'})
Vue.prototype.$auth = authInstance

Upvotes: 1

Related Questions