Closed jparish3 closed 4 years ago
Just a quick note letting you know that we are looking into it now. We purposefully configured the api to allow all ALL origins to call the API. We are checking what's wrong with that configuration.
Hey @jparish3 ! It was a config issue. The problem is fixed! Please try again and let us know whether it works or not.
Here is my test code running in a localhost website. It's able to retrieve the data correctly with our config fix.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$.ajax({
type: "GET",
url: "https://api.smartable.ai/coronavirus/stats/US",
// Request headers
beforeSend: function(xhrObj) {
xhrObj.setRequestHeader("Cache-Control", "no-cache");
xhrObj.setRequestHeader("Subscription-Key", "<replace this with your own key>");
},
})
.done(function (data) {
alert(data.updatedDateTime);
})
.fail(function () {
alert("error");
});
</script>
thanks for the quick fix. I am able to get through using axios, but have not figured out to pass credentials using fetch:
fetch('https://api.smartable.ai/coronavirus/news/CA', {
'Cache-Control': 'no-cache',
'Subscription-Key': '
let me know if you have any suggestions for fetch , but axios will work fine
You need to get a free subscription key by signing up or signing into our developer portal (https://developer.smartable.ai), go to your profile, click 'generate a new subscription' if you haven't done so, choose 'Free APIs', give it a name and click 'Subscribe'. Then you will get a key. Copy and paste the key to
'Subscription-Key': '<put the key here>'
And you should be able to call the API
Here is a screenshot of the last step to retrieve the key.
I am trying to access the COVID-19 from a web app in development using local host. I have tried to use the request configurations for javascript but keep getting blocked by CORS (see below). Do you have a fetch or axios config that would work ? the API looks great and I would like to resolve my issue. Thanks
...has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.