AngularJS TypeError: Cannot read property ‘then’ of undefined

This occurs if you forget to return the item that originally defines .then

For instance, my that caused this was in a function I was calling and it looked like this:

            $http.get(myurl) //, {params:params})
	    .then(
	    	function(response){
	    		return response;
	    	},
	    	function(response){
	    		return response
	    	}
	    ); 

I needed to add ‘return ‘ to it as follows:

            return $http.get(myurl) //, {params:params})
	    .then(
	    	function(response){
	    		return response;
	    	},
	    	function(response){
	    		return response
	    	}
	    ); 

I hope this helps someone else.

3 thoughts on “AngularJS TypeError: Cannot read property ‘then’ of undefined

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s