Hi everyone I work on webpack and VueJS and I want to use a function in multiple different scripts but I don't want to write the script of these function many times. So I have 2 files where I want to use my function like this :
export default {
data(){
return {
metadata: null,
}
},
methods:{
},
mounted(){
this.metadata = this.httpGet("myurl");
}
}
And like this :
export default {
data(){
return {
metadata: null,
}
},
methods:{
},
mounted(){
this.metadata = this.httpGet("myurl");
}
}
And this is the third part where i want to create my function :
httpGet(theUrl){
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", theUrl, false); // true for asynchronous request
xmlHttp.send(null);
return JSON.parse(xmlHttp.responseText);
}
I don't found the exact code to make it works. So please tell me how I can use imports, require or things like this. I don't want to use vuex because it is to complex for the little thing I want to do. The final objective is to get a script where I can store different functions and use them in multiples others scripts.