-async function load(): Promise<void> {
- if (state.isLoading === true) return
- state.isLoading = true
- const listChargingStationsPayload = await UIClientInstance.listChargingStations()
- state.chargingStations =
- listChargingStationsPayload.chargingStations as unknown as ChargingStationData[]
- state.isLoading = false
+const loadChargingStations = (reloadCallback?: () => void): void => {
+ if (state.isLoading === false) {
+ state.isLoading = true
+ uiClient
+ .listChargingStations()
+ .then((response: ResponsePayload) => {
+ if (app != null) {
+ app.appContext.config.globalProperties.$chargingStations = response.chargingStations
+ }
+ })
+ .catch((error: Error) => {
+ $toast.error('Error at fetching charging stations')
+ console.error('Error at fetching charging stations:', error)
+ })
+ .finally(() => {
+ if (reloadCallback != null) {
+ reloadCallback()
+ }
+ state.isLoading = false
+ })
+ }