Working on integrating my Angular App with Azure Services as the back end.
Initially, I used the standard $http call:
$http({
method: 'POST',
url: "https://services.example.com/Api/myApi",
headers : {
"Content-Type": "application/json",
"Ocp-Apim-Subscription-Key": "my-key"
},
data : post,
success : function(data,status) {
console.log(data + " " + status);
},
failure : function(err) {
console.log(err)
}
However, I kept receiving a 200 response code along with an error stating "No 'Access-Control-Allow-Origin' header is present on the requested resource". Despite confirming CORS settings were open with the Back End developer, the issue persisted.
Later, I attempted to integrate using https://github.com/TerryMooreII/angular-azure-mobile-service. The integration seemed logical, and the new call appeared as follows:
Azureservice.invokeApi('myApi', {
method: 'post',
body: {
data: 'Cheese'
},
headers : {
'Content-Type' : 'application/json'
}
})
.then(function(response) {
console.log('Here is my response object');
console.log(response)
}, function(err) {
//console.error('Azure Error: ' + err);
});
Unfortunately, upon implementing this approach, I encountered the following ambiguous error message: OPTIONS MobileServices.Web-1.1.2.min.js:2
t.DirectAjaxTransport.t.performRequest @ MobileServices.Web-1.1.2.min.js:2t.Platform.t.webRequest @ MobileServices.Web-1.1.2.min.js:2t.MobileServiceClient.MobileServiceClient._request @ MobileServices.Web-1.1.2.min.js:2(anonymous function) @ MobileServices.Web-1.1.2.min.js:2t.Platform.t.async @ MobileServices.Web-1.1.2.min.js:2Promise @ MobileServices.Web-1.1.2.min.js:2t.Platform.t.async @ MobileServices.Web-1.1.2.min.js:2invokeApi @ angular-azure-mobile-service.min.js:1$scope.submit @ form.js:30$a.functionCall @ angular.js:10567(anonymous function) @ angular.js:18627$get.h.$eval @ angular.js:12412$get.h.$apply @ angular.js:12510(anonymous function) @ angular.js:18626n.event.dispatch @ jquery.js:4435n.event.add.r.handle @ jquery.js:4121
This resulted in yet another Access-Control-Allow-Origin header error combined with a 404 response!
Any insights on how to address this?