When working within a Vue component, I have a scenario where I am invoking a function from a separate JavaScript file. The requirement is to then trigger a method within my component once the first function has finished executing:
Here is an example of my .vue component:
import myFunction from '@/components/functions';
export default {
name: 'test',
components: {
myFunction,
},
created(){
if (....) {
myFunction.function1(myParam)
.then((response) => {
this.method2();
});
},
methods:{
method2(){
something;
},
}
};
And here is the contents of my separate functions.js file:
export default {
function1(myParam) {
...
return true;
},
};
Despite trying different approaches, like the one I've included in my code, I keep encountering an error message:
.function1(...).then is not a function
I am confident that the solution is not overly complex, but I am struggling to identify the correct syntax to make it work.