I am new to Javascript and Angular. I am trying to move from an $httpbackend mock server using straight JSON data from a file like [{"firstName":"James",...}...] to getting the data from a live REST server to try out my client code (backand).
On my client I use the http service as follows:
return $http.get(serviceUrlBase).then(getAllcontactsSuccess, getAllcontactsError);
// Promises
function getAllcontactsSuccess(response)
{
return response.data.data;
}
The 'response data.data' returns this:
{"data":[{"__metadata":{"id":"1"},"id":1,"firstName":"James","lastName":"Bud","email":"[email protected]","phone":"504-621-8927","street":"6649 N Blue Gum St","city":"New Orleans","state":"LA","zip":"70116"},{"__metadata":{"id":"2"},"id":2,"firstName":"Josephine","lastName":"Darakjy","email":"[email protected]","phone":"810-374-9840","street":"4 B Blue Ridge Blvd","city":"Brighton","state":"MI","zip":"48116"},...]}
I read a lot of similar questions and I am trying to write an httptransformer but whatever I try is not working. I cant get rid of the "__metadata":{"id":"1"}, section which seem to be the issue as it is seen as a additional field when carrier over in the controller.
Any ideas is appreciated.
__metadatain the service call?