Skip to content

Instantly share code, notes, and snippets.

@codeaholicguy
Created December 25, 2016 16:25
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 codeaholicguy/6085c65066cd20e91a47caed37182c1e to your computer and use it in GitHub Desktop.
Save codeaholicguy/6085c65066cd20e91a47caed37182c1e to your computer and use it in GitHub Desktop.
import SoundCloud from 'soundcloud';
import {ActionTypes} from '../core/constants';
const API_HOST = '//api.soundcloud.com';
export function auth() {
return (dispatch) => {
SoundCloud.connect().then((session) => {
dispatch(fetchMe(session));
});
}
}
function fetchMe(session) {
return (dispatch) => {
fetch(`${API_HOST}/me?oauth_token=${session.oauth_token}`)
.then((res) => res.json())
.then((user) => {
dispatch((user) => ({type: ActionTypes.ME_SET, user}))
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment