Response headers in test server in JavaScript

Our server is able to send different HTTP headers. For this, the second parameter of a callback is used:

export default { '/handler/': function(data, resp) { // resp parameter for headers } }

Using the setHeader method, we can set any header. For example, let's set the MIME type to JSON:

export default { '/handler/': function(data, resp) { resp.setHeader('Content-Type', 'application/json'); return '[1,2,3]'; } }

Set the Content-Type header to text/plain.

enru