UI: fix api paths for target charging; better error handling (#6116)

This commit is contained in:
Michael Geers 2023-02-07 10:48:08 +01:00 • committed by GitHub
parent 4ff0b9a5fd
commit 98351bdde1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View file

@ -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);
}

View file

@ -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);
}