Skip to content

Instantly share code, notes, and snippets.

@karlbright
Created November 30, 2015 04:24
Show Gist options
  • Save karlbright/925e70aa3dfa30a3ee81 to your computer and use it in GitHub Desktop.
Save karlbright/925e70aa3dfa30a3ee81 to your computer and use it in GitHub Desktop.
import fetch from 'isomorphic-fetch'
import QS from 'qs'
const URL_PREFIX = 'https://www.googleapis.com/youtube/v3'
const PLAYLIST_ID = 'UUANLZYMidaCbLQFWXBC95Jg'
const API_KEY = 'XXX'
const DEFAULT_PART = 'contentDetails'
const DEFAULT_MAX_RESULTS = '50'
function buildUrl(path, params) {
params = QS.stringify(Object.assign({}, { part: DEFAULT_PART, key: API_KEY }, params))
return URL_PREFIX + path + '?' + params
}
export function videos (playlistId) {
fetch(buildUrl('/playlistItems', { playlistId }))
.then(response => console.log(response))
}
videos(PLAYLIST_ID)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment