Trying to connect to an API from angular and I get the following error:
XMLHttpRequest cannot load https://web/api/beta/ruc. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.
the code is the following ...
var app = angular.module("app", []);
app.controller("HttpController", function ($scope, $http, $httpParamSerializer) {
$scope.GetData = function () {
var data = $httpParamSerializer({
token : "c664bfba-9969-4e57-ab7a-4532bc81670b-ef3868a6-e62f-45c8-9a36-92db7c21a353",
ruc : "10178520739"
});
var config = {
headers : {
'Content-Type': 'application/x-www-form-urlencoded;'
}
}
$http.post('https://web/api/beta/ruc', data, config)
.then(function (data) {
$scope.response = "Exito" + data;
})
.then(function (data) {
$scope.response = "Error: " + data;
});
};
});
If you want the more detailed example and the web to which I do the API can access link