I have this function in a Vuejs File which calls another function which is imported from a JS File.
Demo.vue
import Data from "demofile.js"
created(){
this.getResult()
}
methods(){
async getResult(){
Data.example() // Fetching Data from API
.then((results) =>{
this.$set(this,"results",results) // storing in event data()
console.log(this.results)
})
.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.