Skip to content

Commit

Permalink
Fix Server error (nightscout#7784)
Browse files Browse the repository at this point in the history
* check if d1 is not nil before call getTime

Co-authored-by: Sulka Haro <sulka@sulka.net>
  • Loading branch information
Joerg-Schoemer and sulkaharo committed Jan 1, 2023
1 parent 6ad4ef1 commit ba76940
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions lib/api/treatments/index.js
Expand Up @@ -63,18 +63,20 @@ function configure (app, wares, ctx, env) {
}
});

if (!_isNil(d1)) res.setHeader('Last-Modified', d1.toUTCString());

if (ifModifiedSince && d1.getTime() <= moment(ifModifiedSince).valueOf()) {
res.status(304).send({
status: 304
, message: 'Not modified'
, type: 'internal'
});
return;
} else {
return res.json(results);
if (!_isNil(d1)) {
res.setHeader('Last-Modified', d1.toUTCString());

if (ifModifiedSince && d1.getTime() <= moment(ifModifiedSince).valueOf()) {
res.status(304).send({
status: 304
, message: 'Not modified'
, type: 'internal'
});
return;
}
}

return res.json(results);
}

// List treatments available
Expand Down

0 comments on commit ba76940

Please sign in to comment.