Skip to content

Instantly share code, notes, and snippets.

@Samiulcse
Last active May 16, 2022 07:00
Show Gist options
  • Save Samiulcse/21f94e05ab0378667564b3295aa3b84d to your computer and use it in GitHub Desktop.
Save Samiulcse/21f94e05ab0378667564b3295aa3b84d to your computer and use it in GitHub Desktop.
loadYoutube(){
axios.create().get('https://www.googleapis.com/youtube/v3/channels', {
params: {
part: "contentDetails",
id: process.env.MIX_YOUTUBE_CHANNEL_ID,
key: process.env.MIX_GOOGLE_API_KEY,
},
headers: {
'Authorization': '',
}
}).then((response) => {
this.loadYoutubeVideos(response.data.items[0].contentDetails.relatedPlaylists.uploads, '')
});
},
loadYoutubeVideos(playListId, pageToken){
axios.create().get('https://www.googleapis.com/youtube/v3/playlistItems', {
params: {
part: "contentDetails,snippet",
playlistId: playListId,
key: process.env.MIX_GOOGLE_API_KEY,
maxResults: this.maxResults,
pageToken: pageToken
},
headers: {
'Authorization': '',
}
}).then((res) => {
if(pageToken == ''){
this.ytVideos = res.data.items.map(item => {
return {
id: item.contentDetails.videoId,
type: 'y',
playlist: playListId,
preview_image_thumbs: item.snippet.thumbnails.medium.url
}
})
}
// if(res.data.nextPageToken){
// this.loadYoutubeVideos(playListId, res.data.nextPageToken)
// }
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment