web app boilerplate

This commit is contained in:
Klemek
2019-09-26 11:13:41 +02:00
parent 17915ec7e9
commit dba1fb6c66
6 changed files with 73 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
/* exported app */
let app = {
el: '#app',
data: {
sample: 'Wikipedia translator'
},
methods: {},
'mounted': {},
'created': {}
};
window.onload = () => {
app = new Vue(app);
};
+17
View File
@@ -0,0 +1,17 @@
/* exported utils */
const utils = {
get: (url, proxy = false) => {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
if (proxy) {
const http = (window.location.protocol === 'http:' ? 'http:' : 'https:');
url = http + '//cors-anywhere.herokuapp.com/' + url;
}
xhr.open("GET", url);
xhr.onload = () => resolve(xhr.responseText);
xhr.onerror = () => reject(xhr.statusText);
xhr.send();
});
}
};