mirror of
https://github.com/kevin-DL/sapper-template.git
synced 2026-01-23 23:11:29 +00:00
replace 4xx and 5xx with _error, per 0.14
This commit is contained in:
@@ -6,8 +6,8 @@ posts.forEach(post => {
|
||||
});
|
||||
|
||||
export function get(req, res, next) {
|
||||
// the `slug` parameter is available because this file
|
||||
// is called [slug].json.js
|
||||
// the `slug` parameter is available because
|
||||
// this file is called [slug].json.js
|
||||
const { slug } = req.params;
|
||||
|
||||
if (lookup.has(slug)) {
|
||||
@@ -17,6 +17,12 @@ export function get(req, res, next) {
|
||||
|
||||
res.end(lookup.get(slug));
|
||||
} else {
|
||||
next();
|
||||
res.writeHead(404, {
|
||||
'Content-Type': 'application/json'
|
||||
});
|
||||
|
||||
res.end(JSON.stringify({
|
||||
message: `Not found`
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user