I'm using axios in my cue project and trying to set some custom default setting to use it.
So i made a axios.js file
import axios from 'axios'
const API_URL = 'http://localhost:8081'
export default axios.create({
baseUrl: API_URL,
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + localStorage.token
}
})
then i mounted it in here /components/axios/index.js using my axios
import Vue from 'vue'
import VueAxios from 'vue-axios'
import axios from './axios'
Vue.use(VueAxios, axios)
In this way i should have set globally axios with my settings right?
So in my Login.vue component file i call this method
login() {
this.$http
.post("/oauth/token", {
username: this.email,
password: this.password,
client_id: "test",
client_secret: "test",
grant_type: "password"
},
)
.then(request => this.loginSuccessful(request))
.catch(() => this.loginFailed());
}
but $http does not have my custom settings but axios generic