Here is an interesting blog about handling http error using boom with custom message. As per the requirment we can put custom message here so that error comes with proper error message.
Boom provides set of utilities for returning HTTP errors. we can make it custom for sending proper error message along with http error.
Pre required plugins
var Boom=require('boom')
Using boom plugings a user can be authenticated along with custom error message.
Boom.unauthorized([message],[schema],[attributes])
here 'message' is optional,
'schema' can be an authentication schema name or array of string values.
'attributes'- attributes is an object of values to user in case setting the 'www-authenticate' header.
Here is code:
Example: #1
No comments:
Post a Comment