question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I am still unclear how redux-api should be used from the docs:

If I have a rest object like this

export default reduxApi({
  getCountries: {
    url: `/countries`,
    transformer(data) {
      const d = fromJS(data);
      return d;
    }
  }
}).use('options', (url, params, getState) => {
  const headers = {
    Accept: 'application/json',
    'Content-Type': 'application/json'
  };

  return { headers };
});

What happens with the result? How do I get the data into the global sate. I can see some sort of name spaced action is raised:

@@redux-api@getCountries_success

Should I have case in a switch statement to test for this.

I’m confused what happens after the asyn call returns

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
EduardoACcommented, Jul 20, 2017

I will try to help as well:

What happens with the result? How do I get the data into the global sate

The truth is that redux api push the data directly to the state of your redux application by using the path defined in the object passed to reduxApi() function.

Which means that the data will store in the variable call getCountries as object that will contain the information above mention.

In order to use in your component you will need to use mapStateToProps from connect something like

const mapStateToProps = state => ({
  countries: state.getCountries 
});

const mapDispatchToProps = dispatch => ({
  getCountries: () => dispatch(api.actions.getCountries()),
});

export default connect(mapStateToProps, mapDispatchToProps)(CountriesComponent);
0reactions
dagda1commented, Jul 21, 2017

Actually the problem was my reducer, changing it to this fixed my problem:

export default function createReducer(asyncReducers) {
  return combineReducers({
    form,
    application: applicantReducer,
    api: combineReducers(reduxApi.reducers)
  });
}

Calling combineReducers on the reduxApi.reducers was the missing bit for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typical Definition & Meaning - Merriam-Webster
The meaning of TYPICAL is combining or exhibiting the essential characteristics of a group. How to use typical in a sentence.
Read more >
Typical usage Definition | Law Insider
Typical usage is up to seven units per day; direct service time associated with providing transportation to/from the program is included in the...
Read more >
typical adjective - Oxford Learner's Dictionaries
1having the usual qualities or features of a particular type of person, thing, or group synonym representative a typical Italian café This is...
Read more >
Usage of the word "typical" - meaning - English Stack Exchange
One can say "Bob typically buys all the beer!", and that doesn't sound negative at all! · "Well, that's typical" (and a few...
Read more >
Typical usage scenarios - IBM
Typical usage scenarios. The following scenarios describe some usage scenarios using the Tivoli® Enterprise Portal and ITCAM for SOA to monitor and diagnose ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found