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

    How do I use quasar boot/axios to receive dynamic url and method from function?

    Help
    2
    4
    605
    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.
    • C
      Christal last edited by

      How do I use quasar boot/axio to receive dynamic url and method from function?

      I have below code at the moment, but I am not sure about passing dynamic data

      import Vue from 'vue'
      import axios from 'axios'
      import { Cookies } from 'quasar'
      
      axios.defaults.baseURL = process.env.BASE_URL
      //need to pass method and url to the axio call
      const axiosInstance = axios.interceptors.response.use(function (response) {
        return response;
      }, async function (error) {
      })
      
      export { axiosInstance }
      
      metalsadman 1 Reply Last reply Reply Quote 0
      • metalsadman
        metalsadman @Christal last edited by

        @Christal just expose a function that sets.axios.defaults.baseURL from your bootfile.

        1 Reply Last reply Reply Quote 0
        • C
          Christal last edited by

          @metalsadman Do you have any sample?

          metalsadman 1 Reply Last reply Reply Quote 0
          • metalsadman
            metalsadman @Christal last edited by metalsadman

            @Christal something like this

            //boot/axios.js
            ...
              export const setBaseUrl = url => {
                axios.defaults.baseURL = url
              }
            ...
            //SomePage.vue
            ...
            import { setBaseUrl } from 'boot/axios'
            ...
              setBaseUrl(newUrl)
            ...
            
            1 Reply Last reply Reply Quote 0
            • First post
              Last post