Comments (4)
ApplicationsActions.getApplications may not be dispatching that's why the Store is deaf to the API response. This snippet from Creating Actions page shows how to dispatch within an action that performs an async operation:
...
fetchUser(id) {
return function (dispatch) {
dispatch(id);
return http.get('/api/users/' + id)
.then(this.fetchUserSuccess.bind(this))
.catch(this.fetchUserFailure.bind(this));
};
},
...
from alt.
Try moving dispatch()
inside the Promise chain: Remove the line that has dispatch()
and replace return (resp.data)
with dispatch(resp.data)
from alt.
Hey that worked !
Thanks a lot !!
from alt.
@avdeveloper That worked ! Thanks a lot !
But now i am not able to get the response from the action.
My Action
import alt from '../util/alt'
import Api from '../util/Api'
class ApplicationsActions {
getApplications(internship){
return function(dispatch){
dispatch();
Api.get('/application',{
internship:'59e34a9eda9fee4c61ff6da6'
}).then(function(resp){
console.log(resp)
return (resp.data)
})
}
}
}
export default alt.createActions(ApplicationsActions);
My Store
import alt from '../util/alt'
import ApplicationsActions from '../actions/ApplicationsActions'
class ApplicationsStore {
constructor(){
this.bindAction(ApplicationsActions.getApplications,this.getApplications)
this.state = {
applications:[]
};
}
getApplications = (applications) => {
console.log(applications)
this.state.applications = applications
}
}
export default alt.createStore(ApplicationsStore,'ApplicationsStore')
applications
inside getApplications(applications)
is undefined .
Thanks again !
from alt.
Related Issues (20)
- Is this still alive? HOT 2
- sequentially perform actions that require source retrieval at same time HOT 2
- Error handler does not get triggered for ajax calls HOT 4
- Wait for store function to complete
- Different tests competing in modifying the store
- Multiple input in controlled forms
- Public Method returns state not store; am I guaranteed the Store is updated when the listener fires? HOT 1
- PropTypes in React 16 Deprecated HOT 2
- dispatchIdentity rudely omit all params when the first one is undefined.
- Upgrade to Webpack 3 HOT 1
- can not call DataSource function during an action
- Typescript does not work
- Using bindListeners vs Store.listen emits changes several seconds slower HOT 1
- docs specify file that does not exists
- How to test async actions
- ss state in compoennts HOT 2
- Trato de hacer la mostrar mis registros en paginas HOT 1
- Documentation needs to be fixed HOT 4
- Documentation needs to be fixed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alt.