Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Last active November 9, 2018 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save productioncoder/cc9232e4e567121e9840cbe9e3153859 to your computer and use it in GitHub Desktop.
Save productioncoder/cc9232e4e567121e9840cbe9e3153859 to your computer and use it in GitHub Desktop.
Youtube in React: parse related videos response
function reduceRelatedVideosRequest(responses) {
const relatedVideosResponse = responses.find(r => r.result.kind === SEARCH_LIST_RESPONSE);
const {pageInfo, items, nextPageToken} = relatedVideosResponse.result;
const relatedVideoIds = items.map(video => video.id);
return {
totalResults: pageInfo.totalResults,
nextPageToken,
items: relatedVideoIds
};
}
export const SEARCH_LIST_RESPONSE = 'youtube#searchListResponse';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment