req.accepts()

Checks whether this request's stated list of "accepted" media types includes the specified type. Returns true or false.

Usage

req.accepts(type);

Example

req.accepts('application/json');
// -> true
req.accepts('json');
// -> true

Notes

  • See the accepts module for the finer details of the header parsing algorithm used in Sails/Express/Koa/Connect.