Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can you supply a example with utils/api {get} #197

Open
jiqimaogou opened this issue Apr 12, 2017 · 1 comment
Open

can you supply a example with utils/api {get} #197

jiqimaogou opened this issue Apr 12, 2017 · 1 comment

Comments

@jiqimaogou
Copy link

No description provided.

@fabriziomoscon
Copy link
Contributor

I am not sure if this help, but in my app I am using it as follows with "redux-thunk": "~2.2.0"

import {
    get as apiGet,
    patch as apiPatch,
} from '../utils/api'

export function APIfindProfileInfo() {
    return function(dispatch, getState) {
        dispatch(loadProfileStart())
        return apiGet('https://yourdomain/accounts?id=1', false)
            .then(data => {
                if (!data || !data.account_profile) {
                    dispatch(loadAccountProfileFailure(new Error('no account profile returned')))
                    return
                }
                dispatch(loadAccountProfileSuccess(data))
            })
            .catch(err => dispatch(loadAccountProfileFailure(err)) )
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants