From 98351bdde1ad320179627404fca92fe4af9068be Mon Sep 17 00:00:00 2001 From: Michael Geers Date: Tue, 7 Feb 2023 10:48:08 +0100 Subject: [PATCH] UI: fix api paths for target charging; better error handling (#6116) --- assets/js/api.js | 7 +++++-- assets/js/components/TargetCharge.vue | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/assets/js/api.js b/assets/js/api.js index c84c3008a..3ca9d5caa 100644 --- a/assets/js/api.js +++ b/assets/js/api.js @@ -15,8 +15,11 @@ const api = axios.create({ api.interceptors.response.use( (response) => response, (error) => { - const url = error.config.baseURL + error.config.url; - const message = `${error.message}: API request failed ${url}`; + let message = error.message; + if (error.config) { + const url = error.config.baseURL + error.config.url; + message += `: API request failed ${url}`; + } window.app.error({ message }); return Promise.reject(error); } diff --git a/assets/js/components/TargetCharge.vue b/assets/js/components/TargetCharge.vue index 4be6c15ef..832a75f2d 100644 --- a/assets/js/components/TargetCharge.vue +++ b/assets/js/components/TargetCharge.vue @@ -242,16 +242,17 @@ export default { if ( this.isModalVisible && !this.timeInThePast && - (this.targetEnergy || this.targetSoc) + (this.targetEnergy || this.targetSoc) && + !isNaN(this.selectedTargetTime) ) { try { const opts = { params: { targetTime: this.selectedTargetTime }, }; this.plan = ( - await api.get(`/loadpoints/${this.id}/target/plan`, opts) + await api.get(`loadpoints/${this.id}/target/plan`, opts) ).data.result; - this.tariff = (await api.get(`/tariff/planner`)).data.result; + this.tariff = (await api.get(`tariff/planner`)).data.result; } catch (e) { console.error(e); }