Hi there, thank you so much for your help!
I'm just starting out with Angular and I'm facing some challenges trying to consume data from an API for my application. The main issue I'm encountering is related to CORS:
In order to run a local HTTP server, I've opted to use the one that comes with Node.js (utilizing the http-server command). For testing purposes, I'm using . Despite generating different responses with headers sourced from various online resources in an attempt to resolve the CORS problem (always running into preflight errors), nothing seems to be working. In my save method within a factory, I've included the following code snippet:
save: {
method: 'POST',
headers: {
'Access-Control-Allow-Origin': '*'
}
}
When utilizing a Chrome extension called CORS, I can bypass the issue and receive a response. However, this prevents me from properly handling promises to access the data within the response. My goal is to display the JSON response on the view.
$scope.submitForm = function() {
var promise = null;
promise = CheckFactory.save($scope.partner).$promise;
$scope.result = promise.data;
}
This function sends form data to the factory and initiates the request. Unfortunately, I'm having trouble navigating how to effectively manage the necessary data from the response.
Thank you for your assistance in advance :)