1
I am trying to access a web service that receives in Header "Device" and in Body "User and Password", it returns me json in this format:
{
"IdUsuario": 2,
"Usuario": "Fulanu",
"Token": "1f7b87d7"
}
Trying to do it at the angle, follow my code:
$scope.logar = function (){
var data = ({Usuario: "usu",Senha:"sen"});
var config = {
headers : {
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
'data': {Device:"1"}
}
}
$http.post("URL", data,config).success(function(data, status){
console.log(data);
});
};
This is returning me following error:
Xmlhttprequest cannot load . Response to preflight request doesn’t pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested Resource. Origin 'null' is therefore not allowed access.
If you are making a request, set up CORS in your API,
– Marcos Souza