I'm currently working on fetching an array of video (file) URLs from parse.com that match a specific playlist ID obtained from the URL.
var playlistVideos = Parse.Object.extend("playlistVideos");
app.get('/:objectId', function(req, res) {
var objectId = req.params.objectId;
var queryVids = new Parse.Query(playlistVideos);
queryVids.equalTo("playlistObjectID", objectId);
queryVids.find({
success: function(videoResults) {
var videoArray = new Array();
for (var i = 0; i < videoResults.length; i++) {
videoArray[i] = videoResults[i].get("userVid");
videoArray.push(i);
//videoArray.push(videoResults[i].get("userVid"));
}
res.render('watch',
{
videos: videoArray,
title: "test videos"
});
},
error: function(error) {
response.error("No videos found");
console.log(error.message);
}
});
});
When I print out the array to test it, the output is:
[object Object],[object Object],[object Object],[object Object],[object Object]
I'm unsure why it's showing these 5 empty objects when I have 8 corresponding to the playlist ID I'm trying to fetch.
I also tried using the .push method with the commented line and experimented with return(). However, I still haven't had any luck. Essentially, what I want returned is "http://example.com/file.mp4", "http://example.com/file2.mp4", etc.
I would greatly appreciate any assistance!