I'm trying to make API call to some open APIs and getting the same error every time: "TypeError: Failed to fetch". The site is added to CSP trusted sites and CORS allowed origin list. The code is working properly in LWC Playground and I can make this call from Postman. Below is my code:
let endpoint = 'https://sv443.net/jokeapi/v2/joke/Any';
let requestParams = {
method: 'GET',
headers: {
'Content-Type' : 'application/json'//,
//'Access-Control-Allow-Origin' : '*'
}
};
fetch(endpoint, requestParams)
.then(response => {
console.log('in response');
})
.catch(error => {
console.log('error3: ' + error);
});