I am recently use Parse as database to create an online app. However, I notice there is some problem with my code due to Parse's asynchronous propriety.
var courseList=[];
function getUserCourses(user){
var relation = user.relation("Courses");
relation.query().find({
success: function(courses){
courseList = courses;
}
}); }
getUserCourses();
setTimeout(function(){console.log(courseList);},1500);
I just wonder instead of using setTimeout, is there is a better way to execute the Parse's query completely before running to the next line of code. Thanks!