0

I want get JSON objects from my Rest Api. I used GET method in AngularJs. But it gives me an error.

This is an error.

XMLHttpRequest cannot load http://localhost:8080/MealMobile/webapi/meals/meal_type. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access.

This is my controller.

eventApp.controller('requestCtrl',function($scope, $http, $log) {
$http({
    method:'GET',
    url:'http://localhost:8080/MealMobile/webapi/meals/meal_type'})
    .then(function (response) {
            $scope.loginData = response.data;
            $log.info(response);
        }
    );

});

Server is up and url is also working. Therefore I can't find a solution. Can you give me an answer for this..

Jenny
  • 13
  • 4
  • Your application is running on port 8100 and you are accessing a REST api on application running on 8080...the is cross origin – Cyril Cherian Sep 06 '16 at 08:57
  • Possible duplicate of ["No 'Access-Control-Allow-Origin' header is present on the requested resource"](http://stackoverflow.com/questions/20035101/no-access-control-allow-origin-header-is-present-on-the-requested-resource) – Pritish Vaidya Sep 06 '16 at 08:57
  • Check [this](http://enable-cors.org) and copy&paste the code for enable cors in your backend – gianlucatursi Sep 06 '16 at 09:03
  • Adding extension to the chrome gives me a solution.. Thank you – Jenny Sep 06 '16 at 09:35

0 Answers0