Skip to content

Instantly share code, notes, and snippets.

@codeaholicguy
Created February 26, 2017 16:49
Show Gist options
  • Save codeaholicguy/5718fa1cf97eaa888ec2aed54708f6a2 to your computer and use it in GitHub Desktop.
Save codeaholicguy/5718fa1cf97eaa888ec2aed54708f6a2 to your computer and use it in GitHub Desktop.
...
import {setTracks} from '../actions/track';
...
export function auth() {
return (dispatch) => {
SoundCloud.connect().then((session) => {
dispatch(fetchMe(session));
dispatch(fetchTracks(session));
});
}
}
...
function fetchTracks(session) {
return (dispatch) => {
fetch(`${API_HOST}/me/activities?limit=20&offset=0&oauth_token=${session.oauth_token}`)
.then((res) => res.json())
.then((data) => {
dispatch(setTracks(data.collection));
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment