ts-lambda-api - v2.5.2
    Preparing search index...

    Function setHeaders

    • Sets multiple header values for implicit headers. headers must be an instance of Headers or Map, if a header already exists in the to-be-sent headers, its value will be replaced.

      const headers = new Headers({ foo: 'bar' });
      outgoingMessage.setHeaders(headers);

      or

      const headers = new Map([['foo', 'bar']]);
      outgoingMessage.setHeaders(headers);

      When headers have been set with outgoingMessage.setHeaders(), they will be merged with any headers passed to response.writeHead(), with the headers passed to response.writeHead() given precedence.

      // Returns content-type = text/plain
      const server = http.createServer((req, res) => {
      const headers = new Headers({ 'Content-Type': 'text/html' });
      res.setHeaders(headers);
      res.writeHead(200, { 'Content-Type': 'text/plain' });
      res.end('ok');
      });

      Parameters

      • headers: Headers | Map<string, string | number | readonly string[]>

      Returns this

      v19.6.0, v18.15.0