Axios settings/defaults 0.15
-
Hello,
In 0.15 where to place the axios defaults?
For example:defaults.baseURL = ‘https://api.somewhere.com’
or
the defaults.headers.common[‘x-custom-token’] = ‘i1’Where should I put this in the new pwa structure?
Thanks
-
Hi
if you did not choose to use axios during project init:
npm install --save axios quasar new plugin axios
in quasar.conf.js:
module.exports = function (ctx) { return { plugins: [ 'axios' ] } }
Either ways you then edit
/src/plugins/axios.js
to look like this:import axios from 'axios' export default ({ Vue }) => { Vue.prototype.$axios = axios.create({ baseURL: 'http://localhost:80', withCredentials: true // timeout: 1000, // headers: { // 'header': 'value' // } }) }
-
Thank you!
-
How is the axios.interceptors?
-
@lucianoreis I put them right under where you create axios.
Vue.prototype.$axios = axios.create({ baseURL: 'http://localhost:80' }) Vue.prototype.$axios.interceptors.response.use(function (response) {
-
This post is deleted!