Skip to content

Commit

Permalink
updated getLyrics() method to fix lyrics not found issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ni3gup authored Feb 13, 2020
1 parent a425795 commit c27cdfb
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lyrics-search/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,16 @@ async function getLyrics(artist, songTitle) {
const res = await fetch(`${apiURL}/v1/${artist}/${songTitle}`);
const data = await res.json();

const lyrics = data.lyrics.replace(/(\r\n|\r|\n)/g, '<br>');

result.innerHTML = `<h2><strong>${artist}</strong> - ${songTitle}</h2>
<span>${lyrics}</span>`;
if (data.error) {
result.innerHTML = data.error;
} else {
const lyrics = data.lyrics.replace(/(\r\n|\r|\n)/g, '<br>');

result.innerHTML = `
<h2><strong>${artist}</strong> - ${songTitle}</h2>
<span>${lyrics}</span>
`;
}

more.innerHTML = '';
}
Expand Down

0 comments on commit c27cdfb

Please sign in to comment.