0

I am working on angularjs application. When trying to hit the https url ,i am getting the below exception.

XMLHttpRequest cannot load https://xyz.abc.com. No 'Access-Control-Allow-Origin' header is present on the requested resource. 

js code:

controller:

app.controller("myController",["$scope",'MyService',function($scope,MyService){
     MyService.getResposneData().error(function(error){

        console.log("Error");
    }).
    then(function(response){
        $scope.req=response;
        console.log(angular.toJson(response));
    });

}]);

service:

instanceService.getResposneData = function() {
        var prom=$http({
            method: 'GET',
                url:"https://xyz.abc.com"}).
            success(function(response){
                alert("success " + response);
                return response;
            }).
            error(function(err){
                alert("error " + err);
                return err;
            });
            return prom;
        }

Before resolving the exception i got , i want to know how can i pass username and password details in my service call (getResposneData).Any inputs?

sss
  • 5
  • 1
  • 5
  • it's all there https://stackoverflow.com/questions/21455045/angularjs-http-cors-and-http-authentication – couettos Jun 14 '17 at 20:52
  • Its not that clearly mentioned as to how to pass them using angularjs, they showed in PHP and angularjs tags doesn't support them.@couettos – sss Jun 14 '17 at 20:58

0 Answers0