How to create reusable functions in Vuejs?

I have this function in a Vuejs File which calls another function which is imported from a JS File.


import Data from "demofile.js"


async getResult(){
      Data.example() // Fetching Data from API
      .then((results) =>{
        this.$set(this,"results",results) // storing in event data()
    .catch(e =>console.log(e, "Error from catch"))

I want to make this function reusable so that I could use it on any other VueJS files.

Read more here:

Content Attribution

This content was originally published by pranshu verma at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: