javascript - promise and getting response object as null using .then -


i'm getting json data trough web service

myservice.getdata()             .then(function(data, status, headers, config){             alert(data.length);     }... 

even though i'm able data , examine trough browser console inside code in then block i'm getting data undefined.

what i'm doing wrong here?

update: service call looks this

 return $http.post("http:/...", {                   headers: {'authorization': 'basic qwxhzgrpbjpvcgvuihnlc2ftzq==' }               }).success(function(data, status, headers, config){                    return data;               }).error(function(data, status, headers, config){                   alert('err');               }); 

the data passing resolve object , not array.

objects not have length property, calling length on object give undefined unless have assigned length property on it.

var arraylike = ['a', 'b'] console.log(arraylike.length) //outputs: 2  var objectlike = { "a": 1, "b": 2 } console.log(objectlike.length) // outputs: undefined (no length property on object, , b. 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -