question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use it outside vue instance ?

See original GitHub issue

i want to show notification with this plugin every error request in axios interceptor ?

Axios interceptors

axios.interceptors.response.use((response) => {
  return response
}, function (error) {
  console.log('Error Axios Hanlder', error.response)
  this.$notify({
    group: 'foo',
    title: 'Important message',
    text: 'Hello user! This is a notification!'
  })
  return Promise.reject(error)
})

Error

Uncaught (in promise) TypeError: __WEBPACK_IMPORTED_MODULE_2_vue__.default.$notify is not a function
    at eval (index.js?2848:10)
    at <anonymous>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jd-solankicommented, Sep 10, 2020

Anyone managed to call it in axios response interceptor??

0reactions
jgrandarcommented, Sep 26, 2021

It worked for me:

On main.js

import axios from '@/utiles/axios'

Vue.prototype.$axios = axios
Vue.use(Notifications)

const vueInstace = new Vue({
  router,
  store,
  render: h => h(App),
}).$mount('#app')

axios.app = vueInstace

On axios.js

axios.interceptors.response.use(response => response, (error) => {
  if (error.response.status === 422) {
    axios.app.$notify({ type: 'error', text: 'Validation error text.' })
  }
  return Promise.reject(error)
})
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to access data from outside the instance in Vue js?
To access vue.js object datas from inside you can use $property_name. Example. var vm = new Vue({ el: '#app', data() { return {...
Read more >
Accessing a Vue instance outside of its declaration
Learn how to access Vue instances after having declared them and how to change data properties, invoke methods, etc. on already declared Vue ......
Read more >
Vuejs instance variable outside instance - Get Help - Vue Forum
Let's say I want to use/export this selectedPerson to another js script outside the Vue instance. Is this possible??
Read more >
How to Use Vue Router Outside Vue Instance - Nesin.io
How to Use Vue Router Outside Vue Instance ; import router from './router' ; // redirect to different route router.push ; {name:'standard_error'} ...
Read more >
Use objects outside VUE - Laracasts
Hello, I was wondering how to use objects outside VUE. For example, from my Script.vue I want to access an object, how do...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found