Created
December 25, 2016 16:25
-
-
Save codeaholicguy/6085c65066cd20e91a47caed37182c1e to your computer and use it in GitHub Desktop.
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
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