I am trying to get this function to work, I am new to javascript and am doing this for a homework assignment. I attempt the code below however nothing appears as a result. I am pretty sure I am doing something wrong, due to the fact that this is my first time obtaining data from an API. Any tips or help is greatly appreciated.
Code:
function getStudentsInCourse() {
$.get("http://web.cs.somecollege.edu/~doej/web/api/student/getStudents/")
.done(function (data) {
return data;
})
.fail(function (jqXHR, textStatus, errorThrown) {
console.log("Error calling Student/getStudentsInCourse: " + errorThrown);
});
}
call:
var course []
course = getStudentsInCourse();
note:.coursenum referenced from the API itself.
Parameters coursenum - string; unique identifier for a Course
Returns JSON array of objects
Sample data from API:
[
{
"id": "3",
"name": "Jax",
"level": "Junior",
"owner": "public",
"photo_filename": "",
"active": "1"
},
{
"id": "4",
"name": "Ashe",
"level": "Junior",
"owner": "public",
"photo_filename": "",
"active": "1"
}
]