How do I write a custom route? I'd like to write a route that returns 5 users (regardless of how many are in the database), but the available shorthands aren't cutting it.
I looked at the documentation, but I am still confused.
How do I write a custom route? I'd like to write a route that returns 5 users (regardless of how many are in the database), but the available shorthands aren't cutting it.
I looked at the documentation, but I am still confused.
To write a custom route, simply pass a function in as the second argument to your route handler:
this.get('/users', function(db, request) {
return db.users.filter(i => (i < 5));
});