From 1c9e2b8d7025cc9412d4639e22251d06960c000a Mon Sep 17 00:00:00 2001 From: Valentin Kaelin Date: Wed, 1 Jan 2020 16:22:40 +0100 Subject: [PATCH] fix: return old matchList from db if Riot API is down --- server/app/Services/MatchService.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/app/Services/MatchService.js b/server/app/Services/MatchService.js index 7e9a375..e4f6cdf 100644 --- a/server/app/Services/MatchService.js +++ b/server/app/Services/MatchService.js @@ -15,7 +15,12 @@ class MatchService { let alreadyIn = false let index = 0 do { - let newMatchList = (await Jax.Matchlist.accountID(account.accountId, account.region, index)).matches + let newMatchList = await Jax.Matchlist.accountID(account.accountId, account.region, index) + // Error while fetching Riot API + if (!newMatchList) { + return matchList + } + newMatchList = newMatchList.matches matchList = [...matchList, ...newMatchList] alreadyIn = newMatchList.length === 0 || stopFetching(newMatchList) // If the match is made in another region : we stop fetching