DEV Community

Discussion on: Building Vue.js Client SPA Token-Based Authentication with Laravel Sanctum

Collapse
romanpaprotsky profile image
Roman Paprotsky Author

That's a good question, Balázs!

You can add in main.js:

Vue.prototype.$axios = axios
Enter fullscreen mode Exit fullscreen mode

After that in components you can write:

$axios.get('/items')
  .then(function (response) {
    console.log(response)
  })
Enter fullscreen mode Exit fullscreen mode
Collapse
ohidurbappy profile image
Ohidur Rahman Bappy • Edited on

From child component I had to refer using this keyword

this.$axios.get('/items')
  .then(function (response) {
    console.log(response)
  })
Enter fullscreen mode Exit fullscreen mode