mardi 30 décembre 2014

if condition not working in node js

I am working on mobile application with nodejs and mongo db for server side functionality.


I have implemented a custom header to be sent in every request and I have following function to check header values.


Here is my CODE :



/**
*
* Check Request headers
* @param : headers
* @returns : boolean
*
* */
function checkHeaders(data) {
var customHeader = JSON.stringify(data.appsecret).valueOf().trim();
var contentTypeHeader = JSON.stringify(data["content-type"]).valueOf().trim();
if (contentTypeHeader === "application/x-www-form-urlencoded" && customHeader === "xxxxx") {
return 1;
} else {
return 0;
}
}


Here I always get 0 as the response and I have checked the values of all 3 variables i.e.

1. data,

2. customHeader ,

3. contentTypeHeader

are received correct. but the values in if condition are not matched and I always get " 0 " as the result.


Any suggestion would be a great help!


Thanks in Advance!


Aucun commentaire:

Enregistrer un commentaire