diff --git a/resources/assets/js/services/http.js b/resources/assets/js/services/http.js index a65c4c00..753576be 100644 --- a/resources/assets/js/services/http.js +++ b/resources/assets/js/services/http.js @@ -2,19 +2,14 @@ import Vue from 'vue'; /** * Responsible for all HTTP requests. - * - * IMPORTANT: - * If the user has a good enough connection to stream music, he or she shouldn't - * encounter any HTTP errors. That's why Koel doesn't handle HTTP errors. - * After all, even if there were errors, how bad can it be? */ export default { request(method, url, data, successCb = null, errorCb = null) { - return Vue.http[method](url, data).then(successCb, errorCb); + return Vue.http[method](url, data).then(successCb).catch(errorCb); }, - get(url, data = {}, successCb = null, errorCb = null) { - return this.request('get', url, data, successCb, errorCb); + get(url, successCb = null, errorCb = null) { + return this.request('get', url, {}, successCb, errorCb); }, post(url, data, successCb = null, errorCb = null) { diff --git a/resources/assets/js/stores/shared.js b/resources/assets/js/stores/shared.js index 82a52163..fd414fc0 100644 --- a/resources/assets/js/stores/shared.js +++ b/resources/assets/js/stores/shared.js @@ -30,7 +30,9 @@ export default { init(successCb = null, errorCb = null) { this.reset(); - http.get('data', data => { + http.get('data', response => { + var data = response.data; + assign(this.state, data); // If this is a new user, initialize his preferences to be an empty object. @@ -47,7 +49,11 @@ export default { settingStore.init(this.state.settings); window.useLastfm = this.state.useLastfm = data.useLastfm; - }, successCb, errorCb); + + if (successCb) { + successCb(); + } + }, errorCb); }, reset() { diff --git a/resources/assets/js/stores/song.js b/resources/assets/js/stores/song.js index 657fc5d7..80890a8f 100644 --- a/resources/assets/js/stores/song.js +++ b/resources/assets/js/stores/song.js @@ -180,7 +180,9 @@ export default { return; } - http.get(`${song.id}/info`, data => { + http.get(`${song.id}/info`, response => { + var data = response.data; + song.lyrics = data.lyrics; // If the artist image is not in a nice form, don't use it.