redux-simple-fetch

1.0.5 • Public • Published

REDUX SIMPLE FETCH

Redux package for simple fetching data with axios

REQUIRED

GET STARTED

  1. Installation npm install redux-simple-fetch

  2. Info

    // Default initial state
    
    export const initialState = {
      result: null,
      detail: null,
      postPending: false,
      getPending: false,
      getIdPending: false,
      putPending: false,
      deletePending: false,
      getMorePending: false,
      isError: null,
      isFinished: false
    };
    
  3. Setup project

    // Setting reducer
    
    import { combineReducers } from 'redux';
    import reducerReduxApi from 'redux-api/reducer';
    
    const confReducerReduxApi = reducerReduxApi({
      // name reducers
      contacts: 'CONTACS'
    }, {
      // conf reducer
      propList: 'data',
      primaryItemField: 'id'
    });
    
    const appReducers = combineReducers(confReducerReduxApi);
    
    export default appReducers;
    
  4. Usage

    import { post, put, delete, get, get_id, get_more } from 'redux-api/action';
    ...
    ...
    ...
    dispatch(post('CONTACTS', '/api/v2/contacts'))
    .then(res => {
      // the response will be saved in redux and received here
    })
    .catch(err => {
      // error here
    });
    ...
    ...
    ...
    

MORE INFO

Package Sidebar

Install

npm i redux-simple-fetch

Weekly Downloads

1

Version

1.0.5

License

ISC

Unpacked Size

8.8 kB

Total Files

5

Last publish

Collaborators

  • isgiarriza