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.
This commit is contained in:
Chris Shyi
2018-06-09 21:30:26 -04:00
parent 3cf3eef7ac
commit 3e35e52f45
6 changed files with 67 additions and 15 deletions

View File

@@ -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();
}