Created
October 14, 2016 18:18
-
-
Save talkol/6b08bedbd35bcb530202483ff9a9c713 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 _ from 'lodash'; | |
| import * as types from './actionTypes'; | |
| import redditService from '../../services/reddit'; | |
| export function fetchTopics() { | |
| return async(dispatch, getState) => { | |
| try { | |
| const subredditArray = await redditService.getDefaultSubreddits(); | |
| const topicsByUrl = _.keyBy(subredditArray, (subreddit) => subreddit.url); | |
| dispatch({ type: types.TOPICS_FETCHED, topicsByUrl }); | |
| } catch (error) { | |
| console.error(error); | |
| } | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It allows us to use
awaitin the body of the function.