Reputation: 1708
we have angular 2 application and we are trying to use Deezer API, but when I try to send GET request to Deezer I get the given error. I have tried lots of solution like using jsonp and adding 'Access-Control-Allow-Origin' : ' * ' to .htaccess, but none of them was helpful. I have attached the function that I am using in service.
XMLHttpRequest cannot load https://api.deezer.com/search/track?q=emin. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin "www.example.net" is therefore not allowed access.
searchFromDeezer() {
let url = 'https://api.deezer.com/search/' + this.search_type + '?q=' + this.search_value + '';
return this._http.get(url).map(res=>res.json())
}
How I have used jsonp:
like below.
searchFromDeezer() {
let url = 'https://api.deezer.com/search/' + this.search_type + '?q=' + this.search_value + '?callback=JSONP_CALLBACK';
return this._jsonp.get(url).map(res=>res.json())
}
Upvotes: 0
Views: 749
Reputation: 1708
SOLVED
I was trying to use jsonp but was getting error, problem has been fixed after adding
'&output=jsonp&callback=JSONP_CALLBACK' to my link.
Upvotes: 1