Browse Source
Retrieve audio feature data from frontend
Retrieve audio feature data from frontend
Added user_secret field to User. Set up a basic JavaScript function for querying audio feature data from the frontend.master
Chris Shyi
7 years ago
6 changed files with 67 additions and 15 deletions
-
2.gitignore
-
2spotifyvis/models.py
-
28spotifyvis/static/spotifyvis/scripts/user_data.js
-
11spotifyvis/templates/spotifyvis/user_data.html
-
2spotifyvis/urls.py
-
37spotifyvis/views.py
@ -0,0 +1,28 @@ |
|||
/** |
|||
* Retrieves data for a specific audio feature for a certain user |
|||
* @param audioFeature: the audio feature for which data will be retrieved |
|||
* @param clientSecret: the client secret, needed for security |
|||
*/ |
|||
function getAudioFeatureData(audioFeature, userSecret) { |
|||
let httpRequest = new XMLHttpRequest(); |
|||
/* |
|||
* Handler for the response |
|||
*/ |
|||
httpRequest.onreadystatechange = function() { |
|||
if (httpRequest.readyState === XMLHttpRequest.DONE) { |
|||
if (httpRequest.status === 200) { |
|||
let responseData = JSON.parse(httpRequest.responseText); |
|||
// TODO: The data points need to be plotted instead
|
|||
for (let data of responseData.data_points) { |
|||
console.log(data); |
|||
} |
|||
} else { |
|||
alert("There was a problem with the login request, please try again!"); |
|||
} |
|||
} |
|||
}; |
|||
|
|||
let queryString = `/audio_features/${audioFeature}/${userSecret}`; |
|||
httpRequest.open('GET', queryString, true); |
|||
httpRequest.send(); |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue