I am trying to load .json file which have some setting data
server.js code
(function () {
app.factory("configService", ['$http', function ($http) {
return {
getResponders: function () {
var url = 'https://example.com/assets/js/service/config.json',
apiHeaders = {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json;charset=utf-8'
};
return $http({
method: "GET",
url: url,
headers: apiHeaders,
data: {}
}).then(function (res) {
console.log('response : ' + res);
}, function (res) {
console.log('error : '+res);
});
}
};
}]);
})();
and tying to get res but it show error:
Failed to load https://example.com/assets/js/service/config.json: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8678' is therefore not allowed access. The response had HTTP status code 403.