-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.js
38 lines (28 loc) · 850 Bytes
/
scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function FindLyrics(artist, song){
return fetch(`https://api.lyrics.ovh/v1/${artist}/${song}`)
}
const form = document.getElementById('lyrics_form')
form.addEventListener('submit', el =>{
el.preventDefault()
doSubmit()
})
async function doSubmit(){
const lyricsView = document.getElementById('lyricView')
const artist = document.querySelector('#artist')
const song = document.querySelector('#song')
const responseLyric = await FindLyrics(artist.value, song.value)
const data = await responseLyric.json()
lyricsView.innerHTML = data.lyrics
}
/*
async function getLyrics(){
try{
const camiseta = await FindLyrics('teto', "zumzumzum")
console.log(camiseta)
}
catch (error){
console.error("erro ao buscar letra:", error)
}
}
getLyrics()
*/