コード例 #1
0
ファイル: list.js プロジェクト: plouc/flambo
export const fetchCollections = (_options = {}) => (dispatch, getState) => {
    const {
        collections: { perPage, page, sort, filters },
        auth:        { token },
    } = getState()

    const options = {
        perPage,
        page,
        sort,
        filters,
        ..._options,
    }

    dispatch({ type: FETCH_COLLECTIONS_REQUEST, ...options })

    return api.collections.find(options, { apiUrl, token })
        .then(res => {
            dispatch(fetchTime({
                type: FETCH_COLLECTIONS_SUCCESS,
                ...res,
            }))
        })
        .catch(error => {
            dispatch({
                type: FETCH_COLLECTIONS_FAILURE,
                error,
            })
        })
}
コード例 #2
0
ファイル: comments.js プロジェクト: plouc/flambo
export const fetchCollectionComments = (id, _options = {}) => (dispatch, getState) => {
    const {
        collections: { perPage, page, sort, filters },
        auth:        { token },
    } = getState()

    const options = {
        perPage,
        page,
        sort,
        filters,
        ..._options,
    }

    dispatch({ type: FETCH_COLLECTION_COMMENTS_REQUEST, id, ...options })

    return api.collections.comments(id, options, { token, apiUrl })
        .then(res => {
            dispatch(fetchTime({
                type: FETCH_COLLECTION_COMMENTS_SUCCESS,
                id,
                ...res,
            }))
        })
        .catch(error => {
            dispatch({
                type: FETCH_COLLECTION_COMMENTS_FAILURE,
                id,
                error,
            })
        })
}