I'm building a web app that uses Angularjs. In one of my controllers I make a call to the backend that returns the current login status of the user.
$http.get('http://localhost:3000/status')
.success(function(status) {
if (status == 'internal') {
// do stuff...
Even when the requests responds with status equal to 'internal', (status == 'internal') evaluates to false. To test this a bit I put
$http.get('http://localhost:3000/status')
.success(function(status) {
console.log(typeof status)
console.log(status)
console.log(status == "internal")
which prints
string
"internal"
false
Any Ideas about what could be going wring here?
(status === 'internal')
also, can there maybe be some extra whitespace or something like that?internal
or"internal"
(with quotes). I ask becauseconsole.log(typeof status)
would display as a string but you didn't double quote that in your output.