Skip to content

Commit

Permalink
stop page from crashing when api reacted without error code
Browse files Browse the repository at this point in the history
  • Loading branch information
zefanjajobse committed Nov 19, 2023
1 parent 6944aa5 commit 3817a6d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/api/GametoolsApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export class ApiProvider extends JsonClient {
regions: [region],
limit: "1",
});
return result.servers[0];
return result?.servers[0];
}
if (game == "bf1marne") {
return await bf1MarneApi.server({
Expand All @@ -301,7 +301,7 @@ export class ApiProvider extends JsonClient {
service: gameStuff[1],
platform: platform,
});
return result.servers[0];
return result?.servers[0];
}
return await this.getJsonMethod(`/${gameStuff[0]}/detailedserver/`, {
name: encodeURIComponent(serverName),
Expand Down Expand Up @@ -424,7 +424,7 @@ export class ApiProvider extends JsonClient {
});
// hard limit to 4 on main page
if (limit === "4") {
result.servers = result.servers.slice(0, 4);
result.servers = result?.servers?.slice(0, 4);
}
return result;
}
Expand Down

0 comments on commit 3817a6d

Please sign in to comment.