Skip to content

Instantly share code, notes, and snippets.

@Samiulcse
Last active May 16, 2022 07:00
Show Gist options
  • Select an option

  • Save Samiulcse/21f94e05ab0378667564b3295aa3b84d to your computer and use it in GitHub Desktop.

Select an option

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)
// }
});
},
loadSections() {
axios.get(`/api/home-sections?page=${this.current_page}&per_page=${this.per_page}&profile_id=${(this.currentProfile ? this.currentProfile.id : '')}`)
.then((response) => {
response.data.data.forEach(val => {
this.sections.push(val)
if (val.type == 'ad') {
this.contentAd = true
this.adSectionIds.push(val.id)
setTimeout(() => {
this.initSmallAdvertiseSlider(`small_advertise_slider${val.id}`)
}, 200)
}
this.loadMore = false
});
this.last_page = response.data.meta.last_page
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment