I want to call the Deezer API to load songs to show. My dart Code to call the Deezer API is:
void searchForSongs(String searchString) async {
var url = Uri.parse('https://api.deezer.com/search?q=$searchString');
Map<String, String> requestHeaders = {
'Content-type': 'application/json',
'Accept': 'application/xml',
};
var response = await http.get(url, headers: requestHeaders);
var body = json.decode(response.body);
print(body);
}
When I run the app locally everything works fine. But when I deploy the app to Github Pages the code throws the Error:
[Error] XMLHttpRequest cannot load https://api.deezer.com/search?q=kk due to access control checks.
Can anyone tell me why I get this error and how I can fix it?