I'm trying to make a simple call using this RESTful API for charity data. Here is my JQuery code:
$.ajax({
url: 'https://projects.propublica.org/nonprofits/api/v2/search.json?q=america&c_code%5Bid%5D=3',
dataType: "json",
method: "GET",
success: function( data ) {
console.log("success");
},
error: function() {
console.log('failure');
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
When the code is triggered, it returns the following error:
Access to XMLHttpRequest at 'https://projects.propublica.org/nonprofits/api/v2/search.json?q=american&c_code%5Bid%5D=3' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Am I doing something wrong, or is there an issue with the API?
Read more here: https://stackoverflow.com/questions/66270250/ajax-request-to-a-restful-api-giving-cors-policy-error
Content Attribution
This content was originally published by asiegle at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.