Skip to content

Commit f036d18

Browse files
authored
Merge pull request #43 from alan-wu/bugfix/server-error
Add an error when the server is unresponsive and does not return any …
2 parents 1887aba + 0d6da95 commit f036d18

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/components.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export {}
88
declare module 'vue' {
99
export interface GlobalComponents {
1010
DynamicLegends: typeof import('./components/legends/DynamicLegends.vue')['default']
11+
ElAutocomplete: typeof import('element-plus/es')['ElAutocomplete']
1112
ElButton: typeof import('element-plus/es')['ElButton']
1213
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
1314
ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
@@ -24,6 +25,7 @@ declare module 'vue' {
2425
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
2526
ElRow: typeof import('element-plus/es')['ElRow']
2627
ElSelect: typeof import('element-plus/es')['ElSelect']
28+
ElSwitch: typeof import('element-plus/es')['ElSwitch']
2729
FlatmapError: typeof import('./components/FlatmapError.vue')['default']
2830
FlatmapVuer: typeof import('./components/FlatmapVuer.vue')['default']
2931
LegendItem: typeof import('./components/legends/LegendItem.vue')['default']

src/components/MultiFlatmapVuer.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,11 @@ export default {
166166
if (this.requireInitialisation) {
167167
//It has not been initialised yet
168168
this.requireInitialisation = false
169-
fetch(this.flatmapAPI)
169+
const controller = new AbortController();
170+
const signal = controller.signal;
171+
const timeoutId = setTimeout(() => controller.abort(), 5000);
172+
173+
fetch(this.flatmapAPI, {signal})
170174
.then((response) => {
171175
if (!response.ok) {
172176
// HTTP-level errors
@@ -278,6 +282,9 @@ export default {
278282
other()
279283
})
280284
})
285+
.finally(() => {
286+
clearTimeout(timeoutId);
287+
});
281288
} else if (this.initialised) {
282289
//resolve as it has been initialised
283290
resolve()

0 commit comments

Comments
 (0)