Monday, 8 October 2018

How to deal when calling a wrong endpoint using app.get?

I have several endpoints defined. I am doing the automation of all of them and in addition defining some scenarios where I should get an error.

For instance, one of the endpoints is: '/v1/templates'.

Now, imagine that by error, the user types '/v1/templatess'.

I am using app.get to deal with the known endpoints like this:

app.get(
    '/v1/contents/:template_component_content_id',
    controllers.template_component_contents.getById.bind(controllers.template_component_contents)
);

Is there any way to say that in case that the endpoint called does not match with any of the app.get() options, throw an ERROR?

Thanks in advance.



from How to deal when calling a wrong endpoint using app.get?

No comments:

Post a Comment