-
Notifications
You must be signed in to change notification settings - Fork 87
Description
I use fetch in javascript to request data from https://ssl-checker.io/api/v1/check/. Code below. However the browsers CORS policy blocks it and says "No 'Access-Control-Allow-Origin' header is present on the requested resource."
The browser offers opaque response with the option {mode: 'no-cors'}. This lets throught the request, but the result is no data.
const option = {mode: 'no-cors'}; fetch (url, option).then(res => { if (!res) { console.log('Response not ok!'); return; } console.log(res); return res.text(); }).then(data => console.log('data:', data)).catch(error => console.log(error));
I have also tried return res.json(); instead of return res.text();, which results in SyntaxError: Unexpected end of input at 'json()'.
Does the API request require anything more than the url (g.e. 'cnn.com')?
/A