Services and Axios plugin

  • Hi,
    I am trying to figure out how to build a services for my backend API using the axios plugin in quasar 0.15.
    Quasar documentation contains an example of Axios plugin:

    Should I create another plugin called productsService.vue inside quasar plugins directory? How to reference the axios plugin with productsService plugin ?

    Any suggestions?

  • What is this productsService plugin you speak of?

    No, you should not have any .vue files in the src/plugins/ directory. If you create new plugins make sure to use quasar new plugin <plugin-name> so you get correct syntax

    To access axios in a vue file simply use this.$axios, if you kept the default axios plugin config. If you want to use it in another plugin that is loaded after axios, use Vue.prototype.$axios

  • Ok. Of course my mistake - it should be productsService.js located in the src/plugins/ direfctory.

    productsService.js is responsible for passing configuration to my productsService library which is responsible for GET, POST, DELETE calls to my store products API.

    Thank you for your help. Your answer was realy helpful.

Log in to reply

Looks like your connection to Quasar Framework was lost, please wait while we try to reconnect.