Skip to content

Commit

Permalink
servers: fallback to api2.smoo.it if api.smoo.it is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
Istador committed Feb 17, 2024
1 parent 976fb17 commit d4b9921
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/store/xservers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class XServers extends VuexModule {
@Action
async load () {
this.startLoading()

// get server data from the api server
try {
const { data } = await axios.get(
'https://api.smoo.it/servers.json',
Expand All @@ -81,9 +83,22 @@ class XServers extends VuexModule {
},
)
this.loaded(data)
} catch (error) {
console.error(error)
this.failed(error as Error)
} catch (error1) {
console.error(error1)

// fallback to the api2 server
try {
const { data } = await axios.get(
'https://api2.smoo.it/servers.json',
{
timeout: 10000, // 10s
},
)
this.loaded(data)
} catch (error2) {
console.error(error2)
this.failed(error1 as Error)
}
}
}

Expand Down

0 comments on commit d4b9921

Please sign in to comment.