| 13 | }; |
| 14 | |
| 15 | function getSong(){ |
| 16 | fetch(api) |
| 17 | .then(response => { |
| 18 | return response.json(); |
| 19 | }) |
| 20 | .then(data => { |
| 21 | console.log(data); |
| 22 | song.title = data.now_playing.song.title; |
| 23 | song.artist = data.now_playing.song.artist; |
| 24 | |
| 25 | song.bitrate.high = data.station.mounts[0].bitrate; |
| 26 | song.url.high = data.station.mounts[0].url; |
| 27 | |
| 28 | song.bitrate.low = data.station.mounts[1].bitrate; |
| 29 | song.url.low = data.station.mounts[1].url; |
| 30 | }) |
| 31 | .then(() => { |
| 32 | displayInfo(); |
| 33 | }) |
| 34 | .catch(error =>{ |
| 35 | songTitleElement.innerText = error.message; |
| 36 | }); |
| 37 | } |
| 38 | |
| 39 | function displayInfo(){ |
| 40 | songTitleElement.innerText = song.title; |