Interesting problem here. I have restful backend that returns JSON. When I access the api through the browser it returns a validated json array with a json object.
[{"GUID_Auth":null,"Email_Address":"abc@aol,"Measure_Id":1,"Title":"Prop 41"}]
but when I make a $http.get request through angularjs I instead get back a string with escaped quotes
got success: "[{\"GUID_Auth\":null,\"Email_Address\":\"abc@aol\",\"Measure_Id\":1,\"Title\":\"Prop 41\"}]"
Here is a snippet of my angularjs controller code
.controller('MainCtrl', function($scope,$http) {
$scope.GetData = function(){
var responsePromise = $http.get('http://backend.api');
responsePromise.success(function(data,status,headers,config){
console.log('got success: ' + data);
console.log('test'+ data[0].Email_Address)
});
responsePromise.error(function(data,status,headers,config){
alert('ajax failed');
});
},
This is very perplexing any help would be greatly appreciated.
$http is serializing the data, so parse it before returning it
JSON.parse(data)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With