Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Created November 3, 2018 13:45
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/2a5705ac3ab1237e306f6e84fe9d8e3f to your computer and use it in GitHub Desktop.
Save productioncoder/2a5705ac3ab1237e306f6e84fe9d8e3f to your computer and use it in GitHub Desktop.
Youtube: watch details reducer: quick and dirty implementation
function reduceWatchDetails(responses, prevState) {
let byIdEntry = {};
if (responses && responses[0].result.items) {
const video = responses[0].result.items[0];
byIdEntry = {[video.id]: video};
}
return {
...prevState,
byId: {
...prevState.byId,
...byIdEntry,
},
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment