Fix status code for empty responses
This commit is contained in:
parent
99ef2cb9e7
commit
ed9a4cb146
|
@ -14,7 +14,7 @@ export class MessagesResponder {
|
||||||
this.server.get("/messages", (req: Request, res: Response) => {
|
this.server.get("/messages", (req: Request, res: Response) => {
|
||||||
const result = data.getReviews();
|
const result = data.getReviews();
|
||||||
|
|
||||||
res.writeHead(result.toString() ? 200 : 204, typeJson);
|
res.writeHead(!result.toString() ? 200 : 204, typeJson);
|
||||||
res.write(JSON.stringify(result));
|
res.write(JSON.stringify(result));
|
||||||
res.end();
|
res.end();
|
||||||
});
|
});
|
||||||
|
@ -22,7 +22,7 @@ export class MessagesResponder {
|
||||||
this.server.get("/messages/:id", (req: Request, res: Response) => {
|
this.server.get("/messages/:id", (req: Request, res: Response) => {
|
||||||
const result = data.getReviewById(req.params.id);
|
const result = data.getReviewById(req.params.id);
|
||||||
|
|
||||||
res.writeHead(result.toString() ? 200 : 204, typeJson);
|
res.writeHead(!result.toString() ? 200 : 204, typeJson);
|
||||||
res.write(JSON.stringify(result));
|
res.write(JSON.stringify(result));
|
||||||
res.end();
|
res.end();
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue