Wednesday, 15 March 2017

Setting the Response Header Using Express Node

I am using the following code to set the response header:

var express = require("express");
var app = express();

app.get("/",function(req,res){

  res.header('Content-Type','application/json');

  var task = { title :"Do the grocery" }
  res.send(JSON.stringify(task));
});

When I see in my response in Google Chrome I don't see the response header "Content-Type" being set. Am I doing something wrong?



via john doe

No comments:

Post a Comment