Currently, I am working on an Application that utilizes Angularjs. I am trying to call an API and retrieve data using $http.get(). However, I am facing an issue where my API url does not seem to work properly. Interestingly, when I use a URL from a tutorial on w3schools, it functions perfectly. Here is the code snippet in question:
var url = "/api/v1/policycategory/get";
$http.get(url).then(function (response) {
$scope.myString= response.statusText;
});
When I attempt to use my API, the response I receive in the browser looks like this:
[{"id":1,"name":"Dependants only","displayName":"Dependants Only","dateTimeCreated":"2016-05-12T11:58:19.35"},{"id":2,"name":"One adult","displayName":"Single","dateTimeCreated":"2016-05-12T11:58:19.357"},{"id":3,"name":"One adult & dependant(s)","displayName":"Sole Parent","dateTimeCreated":"2016-05-12T11:58:19.363"},{"id":4,"name":"One adult & any dependants","displayName":"Sole Parent Plus","dateTimeCreated":"2016-05-12T11:58:19.367"},{"id":5,"name":"Two adults","displayName":"Couple","dateTimeCreated":"2016-05-12T11:58:19.367"},{"id":6,"name":"Two adults & dependant(s)","displayName":"Family","dateTimeCreated":"2016-05-12T11:58:19.37"},{"id":7,"name":"Two adults & any dependants","displayName":"Family Plus","dateTimeCreated":"2016-05-12T11:58:19.37"}]
It's worth noting that when I use my API, the function inside does not execute as expected.