Return 404 on review ID that returns no review
This commit is contained in:
parent
14e9549599
commit
91480fea64
|
@ -25,9 +25,15 @@ export class MessagesResponder extends ApiRoute {
|
|||
const receiver = req.headers["user-agent"];
|
||||
const result = data.getReviewById(req.params.id);
|
||||
|
||||
res.writeHead(200, typeJson);
|
||||
res.write(JSON.stringify(result));
|
||||
res.end();
|
||||
if (Object.keys(result).length) {
|
||||
res.writeHead(200, typeJson);
|
||||
res.write(JSON.stringify(result));
|
||||
res.end();
|
||||
} else {
|
||||
res.writeHead(404, typeJson);
|
||||
res.write(Responder.requestError("review not found"));
|
||||
res.end();
|
||||
}
|
||||
|
||||
this.logger.log(`${Logger.emp(receiver)} <~ "${req.path}"`);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue