I am trying to learn how to work with API. My objective is to fetch the lyrics for a given artist_name and given track_name from musixmatch api. I tried it with python and everything worked perfectly, now I want to implement it on my localhost(for now) but I am not making any progress.
I am using fetch api of javascript to receive the response. Here's the javascript code:
$("#lyr-sbmt-btn").on('click', function(){
var artist_name = $("#aname").val()
var track_name = $("#tname").val()
console.log(artist_name + track_name)
base_url = "https://api.musixmatch.com/ws/1.1/"
api_key = "i_have_my_api_key_here"
lyrics_matcher = "matcher.lyrics.get"
format_url = "?format=json&callback=callback"
artist_search_parameter = "&q_artist="
track_search_parameter = "&q_track="
api_call = base_url + lyrics_matcher + format_url + artist_search_parameter +
artist_name + track_search_parameter + track_name + api_key
console.log(api_call)
fetch(api_call, {mode:'no-cors'})
.then(res => console.log(res))
})
The url that I send the request to is correct. When I click on that url link it shows me this
Though the link is correct the response that I receive from fetch contains no data. Here's the response:
I have been reading a lot of similar questions on stackoverflow and tried almost all of them but unfortunately none of them worked. If you could help me sort out this problem that would mean a lot