Answer the question
In order to leave comments, you need to log in
How to pass data from promise(axios) to state redux?
componentDidMount(){
axios.post('/', {})
.then(function (response) {
this.props.allDocuments(response.data);
})
.catch(function (error) {
console.log(error);
});
}
Answer the question
In order to leave comments, you need to log in
axios.post('/', {})
.then((response) => {
this.props.allDocuments(response.data);
})
.catch(function (error) {
console.log(error);
});
Specifically in your example, you can just keep a reference to this or use any other options for binding / context forwarding ...
const that = this
that.props...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question