So I have an issue that keeps bugging the hell our of me I was hoping that someone could help me "level up" a bit. I have this function in a service:
this.getChatStreams = function(callback) {
$http.get(envService.read('apiUrl') + '/messaging/chat')
.then(function(response) {
callback(response);
}).catch(function(response) {
callback(response);
});
};
Now that works, yes I'm aware I can do some nicer error handling. However in my call back:
chatService.getChatStreams(function(response) {
$scope.emptychat = true;
if (response.data.conv !== null) {
$scope.emptychat = false;
$scope.chats = response.data.conv;
startChat();
}
});
I get an error in the console:
undefined is not an object (evaluating
response.data.conv
)
response.data.conv
however is null, but not undefined - so what am I doing wrong?
/Peter