Skip to content

Commit

Permalink
fix(summoner): crash on error response
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveVanOpstal committed Sep 17, 2016
1 parent df0c33f commit dc93214
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/server/match/summoner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ export class Summoner {
public get(region: string, name: string, request: IncomingMessage, response: ServerResponse) {
this.getData(region, name, (res) => {
response.writeHead(res.status, this.server.headers);
let summoner = res.json[name.toLowerCase()];
if (res.success && summoner) {
let summonerId = summoner.id.toString();
response.write(summonerId);
this.server.setCache(request.url, summonerId);
if (res.success) {
let summoner = res.json[name.toLowerCase()];
if (summoner && summoner.id) {
let summonerId = summoner.id.toString();
response.write(summonerId);
this.server.setCache(request.url, summonerId);
} else {
response.write(res.data.toString());
}
} else {
response.write(res.data);
response.write(res.data.toString());
}
response.end();
});
Expand Down

0 comments on commit dc93214

Please sign in to comment.