Instructions for the http.response.setHeader method in node.js

  • 2020-05-05 10:52:40
  • OfStack

method description:

Set the header file information.

If the information to be sent already contains a header file, the value of the file behind the method is overwritten.

If a header file needs to pass more than one value, you can use an array.

syntax:


response.setHeader(name, value)

receive parameters:

Type of response header name                  

value                     response header value

example:


response.setHeader("Content-Type", "text/html");
// Or use an array
response.setHeader("Set-Cookie", ["type=ninja", "language=javascript"]);


Related articles: