In previous article we have seen a simple react with redux example. In this article we will add Axios api to it. Axios is used for Promise based HTTP client for the browser and node.js. To know more about axios package, click here.
In this example we will get input name from user and hit a hello world rest endpoint. For running this example you may need to install below packages -
App.js
AppAction.js
AppApi.js
I have created a rest endpoint - http://localhost:8080/sayhello. It is a GET request which accepts name and returns hello name.
AppReducer.js
AppStore.js
Index.js
Output -
In this example we will get input name from user and hit a hello world rest endpoint. For running this example you may need to install below packages -
- redux
- react-redux
- axios
- redux-thunk
App.js
AppAction.js
AppApi.js
I have created a rest endpoint - http://localhost:8080/sayhello. It is a GET request which accepts name and returns hello name.
AppReducer.js
AppStore.js
Index.js
Output -