I am trying to get a response message from jsonp error callback in angularjs, but the response data is undefined. I am returning a response with a 409 http code. If you open the jsonp url directly in the browser, it displays "angular.callbacks._0 ({" message ":" Reset link is incorrect "})", but I can not get this message in the error callback. What am I doing wrong?
// Extend angular app for api requests app.factory('User', function($http) { var User = function(data) { angular.extend(this, data); }; // Send link for password reset to entered email User.reset_password = function() { return $http.jsonp(jsonp_url + 'user/reset_pass?_method=post&user_key=' + user_key + '&callback=JSON_CALLBACK'); }; return User; }); app.controller('ResetPasswordController', function ResetPasswordController($scope, User){ $scope.submit = function() { var response = User.reset_password(); response.then(function(data){ //Success callback }, function(data){ // Error callback console.log(data) // Output: {config : {...}, data: undefined} }); } });
source share