req.accepts()

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

Usage

  1. req.accepts(type);

Example

  1. req.accepts('application/json');
  2. // -> true
  3. req.accepts('json');
  4. // -> true

Notes

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