I'm currently developing a mobile app using Ionic and Angular. I've been facing an error in my code for the past few hours:
function PromiseCtrl($scope, $http) {
$http({
method:'GET',
url:"http://www.omdbapi.com/?t=" + $scope.search + "&tomatoes=true&plot=full",
withCredentials:false
})
.then(function(response){ $scope.data = response.data });
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app>
<div ng-controller="PromiseCtrl">
{{data}}
</div>
</div>
Simply put, this code snippet fetches data from an API and stores it in $scope.details.
Interestingly, it works fine in jsfiddle or Microsoft Edge, but when tested on WebKit, I encounter the following Error. This is a concern as it fails to run properly after compiling with Cordova and testing on Android devices.
Error:
XMLHttpRequest cannot load . Cannot use wildcard in Access-Control-Allow-Origin when credentials flag is true. (14:35:05:491 | error, javascript) at www/index.html