Cover image for Facing Error res.setHeader not a Function

Facing Error res.setHeader not a Function

shailesh6363 profile image Shailesh Waghole ・1 min read

I have to write code to create a node.js server. But after using the res.setHeader method. I am getting an error that res.setHeader is not a function.
Following is my Code:

const http=require('http');

const server=http.createServer((res,req)=>{

Hello This is response from NodeJS>Server

')//this method is used to display the response on the web page




markdown guide

The callback function should be (req,res). The ordering of the arguments matter.
Try the same after changing the order of the arguments because the rest of it looks good to me.


Hello Atul,
After changing the order of param. It's working fine. Thanks For Helping.