req.is()

req.is(type)

Returns true if the incoming request’s “Content-Type” HTTP header field matches the MIME type specified by the type parameter. Returns false otherwise.

// With Content-Type: text/html; charset=utf-8
req.is('html');
req.is('text/html');
req.is('text/*');
// => true

// When Content-Type is application/json
req.is('json');
req.is('application/json');
req.is('application/*');
// => true

req.is('html');
// => false

For more information, or if you have issues or concerns, see type-is.

doc_Express
2016-05-02 16:34:48
Comments
Leave a Comment

Please login to continue.