No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Axios settings/defaults 0.15

    Help
    4
    6
    4220
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      synbits last edited by

      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

      1 Reply Last reply Reply Quote 0
      • benoitranque
        benoitranque last edited by

        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'
            // }
          })
        }
        
        1 Reply Last reply Reply Quote 0
        • S
          synbits last edited by

          Thank you!

          1 Reply Last reply Reply Quote 0
          • L
            lucianoreis last edited by

            How is the axios.interceptors?

            S 1 Reply Last reply Reply Quote 0
            • S
              silentcoast @lucianoreis last edited by

              @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) {
              L 1 Reply Last reply Reply Quote 0
              • L
                lucianoreis @silentcoast last edited by

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • First post
                  Last post