I am trying to route a URL which I am calling fetch
on to a function using koa-router
.
The URL ends with /email/example@example.com
, and is supposed to fetch a user object by their email. The router object defines:
router.get( uri_prefix+'/email/:email', readUserByEmail);
The definition of the function is as follows:
async function readUserByEmail (ctx, next) {
try {
// get params
let _EMAIL = ctx.params.email;
...
}
I know that the router works for other functions (such as get user by id), however, it doesn't seem to invoke the function readUserByEmail
.
I am not sure what the problem is - whether I am not defining the route correctly, or the function (in terms of parameters), or maybe there are other files I should edit, or maybe something else.
Any help or tips would be appreciated