The following code retrieves comments from a comment section of a youtube video. The thing is it retrieves 20 comments and if there is more it retrieves a next token. I am not very experienced using promises so I wonder how can I get all comments in the section until there is no token anymore?
This code is the example code from a npm package called youtube-comment-api
I guess my question is very easy to solve, but right now I have no clue.
Example:
const fetchCommentPage = require('youtube-comment-api')
const videoId = 'DLzxrzFCyOs'
fetchCommentPage(videoId)
.then(commentPage => {
console.log(commentPage.comments)
return fetchCommentPage(videoId, commentPage.nextPageToken)
})
.then(commentPage => {
console.log(commentPage.comments)
})
via R_Valdez
No comments:
Post a Comment