0

I have a cUrl which gives JSON data I want to use that curl in angularjs but It's giving me error

"Error: $sce:insecurl

Processing of a Resource from Untrusted Source Blocked"

Code:

var App = angular.module('App', [  ]);
App.config(['$sceDelegateProvider', function($sceDelegateProvider) {  
    $sceDelegateProvider.resourceUrlWhitelist([
        'self',
        'http://125.99.157.180/suez/dispweigh.php',
    ]);
}]);
    

App.controller('AboutCtrl', function ($scope, $http, $sce){
    var url = $sce.trustAsResourceUrl('http://125.99.157.180/suez/dispweigh.php');
    $http.get(url)
    .then(function (data) {
         $scope.result = data;
    });
});
Community
  • 1
  • 1
NITISH
  • 155
  • 2
  • 15
  • 1
    Any specific reason you are using curl as the backend is an API you can make an ajax call to get the JSON. – Neha Saggam May 08 '18 at 09:46
  • this curl is form raspberry pi so that's why – NITISH May 08 '18 at 09:51
  • What happens when you use a simple `url` instead of one that has been processed with `$sce`? – georgeawg May 08 '18 at 15:18
  • `125.99.157.180/suez/dispweigh.php: No 'Access-Control-Allow-Origin' header is present on the requested resource`. Using `$sce` will not bypass a CORS problem. – georgeawg May 08 '18 at 15:30
  • Even if it is from raspberry pi you could still make an ajax call right? Also if you are getting CORS issue than you must add allow origin header at server side, with a value from where you are making the call. – Neha Saggam May 09 '18 at 04:50

0 Answers0