res.type()

Sets the “Content-Type” response header to the specified type.

This method is pretty forgiving (see examples below), but note that if type contains a "/", res.type() assumes it is a MIME type and interprets it literally.

Usage

  1. res.type(type);

Example

  1. res.type('.html');
  2. res.type('html');
  3. res.type('json');
  4. res.type('application/json');
  5. res.type('png');