Rebase front on vuecli and update deps

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2018-05-18 11:28:29 +02:00
parent f1cb601b46
commit f7117241a4
89 changed files with 8973 additions and 7936 deletions

View File

@@ -1,2 +0,0 @@
export const API_HOST = 'http://0.0.0.0:4000';
export const API_PATH = '/api';

View File

@@ -1,29 +0,0 @@
import { API_HOST, API_PATH } from './_entrypoint';
const jsonLdMimeType = 'application/json';
export default function eventFetch(url, store, optionsarg = {}) {
const options = optionsarg;
if (typeof options.headers === 'undefined') {
options.headers = new Headers();
}
if (options.headers.get('Accept') === null) {
options.headers.set('Accept', jsonLdMimeType);
}
if (options.body !== 'undefined' && !(options.body instanceof FormData) && options.headers.get('Content-Type') === null) {
options.headers.set('Content-Type', jsonLdMimeType);
}
if (store.state.user) {
options.headers.set('Authorization', `Bearer ${localStorage.getItem('token')}`);
}
const link = url.includes(API_PATH) ? API_HOST + url : API_HOST + API_PATH + url;
return fetch(link, options).then((response) => {
if (response.ok) return response;
throw response.text();
});
}

View File