Last active
November 9, 2018 19:55
-
-
Save productioncoder/cc9232e4e567121e9840cbe9e3153859 to your computer and use it in GitHub Desktop.
Youtube in React: parse related videos response
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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