-
-
Save amandeepmittal/3da6f1d46d60b13f02c505b2132d4a3e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// books.js | |
router.get('/:id', (ctx, next) => { | |
let getCurrentBook = books.filter(function(book) { | |
if (book.id == ctx.params.id) { | |
return true; | |
} | |
}); | |
if (getCurrentBook.length) { | |
ctx.body = getCurrentBook[0]; | |
} else { | |
ctx.response.status = 404; | |
ctx.body = 'Book Not Found'; | |
} | |
next(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment