I'm just trying to get the lyrics from the Musixmatch API and console.log
it out in a json format. Nothing too fancy But I End Up getting this Error: NO 'Access-Control-Allow-Origin' Header. The URL that my JS generates works.. If I copy and paste it into the browser it shows the result. But when I do fetch()
It shows error. I Did a Lot of digging for this error and it seems that my browser seems to be blocking it. And all the solutions I found were for the server side. As I don't control the Musixmatch server I Can't do anything about the result not containing a header. And I am A Newb as Js.So What can I do on my side to fix this error? TIA
Here's my Code:
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="js/main.js"></script>
<title>Document</title>
</head>
<body>
</body>
</html>
JavaScript:
const api_key = '***********'
async function GetLyrics(){
const search = 'Where are you now when I need you most?'
const api_link = `http://api.musixmatch.com/ws/1.1/track.search?&q_lyrics=${search}&apikey=${api_key}`;
const result = await fetch(api_link);
let data = await result.json();
console.log(result)
}
GetLyrics()