-3

Help me fix my code. I change the port and restart server, it still not works.

<div ng-repeat="x in records"> {{x.name}} {{x.email}} {{x.number}}</div>

this does not displaying anything

My code here

myApp.controller('myController', function($scope, $http) {    
    $http({
        method : "GET",
        url : "http://localhost:8081/contact"
    }).then(function successCallback(response){
        console.log("success");
        $scope.records = response.data;
    }, function errorCallback(response){
        console.log("error");
    })
});

1 Answers1

0

The Access-Control-Allow-Origin response header indicates whether the response can be shared with resources with the given origin.

So your back end Web service should include your origin (In this example http://localhost:4231) in it's response in Access-Control-Allow-Origin response header. Otherwise it will not share the requested resource.

Syntax of setting this header as below

Access-Control-Allow-Origin: *
OR
Access-Control-Allow-Origin: <origin>
Malatesh Patil
  • 4,505
  • 1
  • 14
  • 14