script.js
//Finding the score of the song using the given spotify song uri
Finding the score of the song using the given spotify song uri
Finding the score of the song using the given spotify song uri
function song_score(song_uri){
  song_uri = String (song_uri)
  uriss = song_uri.substring('spotify:track:'.length);
    async function song_score_gen(){
      const response = await fetch (`https://api.spotify.com/v1/audio-features/${uriss}`,{
          method: 'GET',
          headers: {
              'Accept': 'application/json',
              'Content-Type': 'application/json',
              'Authorization': "Bearer " + access_token
          }
      });
      return response.json();
  }
  var resp = song_score_gen();
  var score = resp.then(data =>{
    sco = data.key + data.mode + data.time_signature + data.acousticness + data.danceability + data.energy + data.instrumentalness + data.liveness + data.loudness + data.speechiness + data.valence + data.tempo;
    return [sco,'spotify:track:'+data.id];
  }) 
  return score
}
function song_score ( song_uri ) { song_uri = String ( song_uri ) uriss = song_uri . substring ( 'spotify:track:' . length ) ; async function song_score_gen ( ) { const response = await fetch ( ` ${ uriss } ` , { method : 'GET' , headers : { 'Accept' : 'application/json' , 'Content-Type' : 'application/json' , 'Authorization' : "Bearer " + access_token } } ) ; return response . json ( ) ; } var resp = song_score_gen ( ) ; var score = resp . then ( data => { sco = data . key + data . mode + data . time_signature + data . acousticness + data . danceability + data . energy + data . instrumentalness + data . liveness + data . loudness + data . speechiness + data . valence + data . tempo ; return [ sco , 'spotify:track:' + data . id ] ; } ) return score }
Finding the score of the song using the given spotify song uri
Finding the score of the song using the given spotify song uri