Created
July 3, 2017 06:31
-
-
Save buckyroberts/7722bad0d26e357cd8e5c96dd3fa7d9a 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 axios from 'axios'; | |
import {normalize} from 'normalizr'; | |
import actionTypes from '../../../config/action-types'; | |
import settings from '../../../config/settings'; | |
import {setNormalized, stringify} from '../../../utils/general'; | |
import {POST} from '../../../utils/normalize'; | |
import {tokenHeader} from '../../../utils/requestHeaders'; | |
export const getPostList = (params = {}) => async dispatch => { | |
const MODEL = 'POSTS'; | |
try { | |
const response = await axios.get(`${settings.API_ROOT}/posts${stringify(params)}`, tokenHeader()); | |
const {entities} = normalize(response.data, [POST]); | |
setNormalized(dispatch, entities); | |
} catch(error) { | |
throw error; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment