Fix status code for empty responses

This commit is contained in:
powermaker450 2024-08-21 03:02:53 -04:00
parent 99ef2cb9e7
commit ed9a4cb146

View file

@ -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();
}) })