I'm currently working with AngularJS version 1.4.3 and here is the code snippet I am using:
angular
.module('app', [])
.run(run);
function run($http) {
a = $http({
method: "GET",
url: 'http://127.0.0.1:8080/test',
data: {}
});
console.log(a);
}
When accessing the URL through a browser or Postman, it works fine. However, I encounter the following error message when executing the provided code:
XMLHttpRequest cannot load . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access.
Interestingly, I am able to retrieve the desired result when using applications, but the code fails to do so. What could be causing this discrepancy?