In vuejs to make a global method?

Hi all.
In vuejs to make a method which I can call from any component?
Just the same method I use in several components and that would not write it for everyone it can as it is placed in a separate file?
And that it is better to use?
methods: {
 getAllCategories() {
axios.get('/api/categories')
 .then(res => this.categories = res.data)
 .catch(err => console.log('Error'));
}
 }

Thank you.
June 3rd 19 at 19:19
2 answers
June 3rd 19 at 19:21
Solution
this is a better option vuex - Arely.Casper commented on June 3rd 19 at 19:24
June 3rd 19 at 19:23
Solution
VueX
, vuex is a global storage facility https://vuex.vuejs.org/ru/guide/ - Arely.Casper commented on June 3rd 19 at 19:26

Find more questions by tags JavaScriptVue.js