Answer the question
In order to leave comments, you need to log in
Having received a json response with nested data, how is it possible to send data to two Reducers?
I call from the view Action in which I eventually get a response from the ajax request.
The received data has the following structure:
{
"departments": [
{
"id": 1,
"name": "General Department",
"operators": [
{
"id": 1,
"name": "Artem Maximum"
},
{
"id": 2,
"name": "Chehonte"
}
]
},
{
"id": 2,
"name": "Sales Department",
"operators": [
{
"id": 3,
"name": "Ne0d1n"
},
{
"id": 4,
"name": "Geronimo"
},
{
"id": 5,
"name": "Fungus"
}
]
}
]
}
{
"entities": {
"departments": {
"1": {
"id": 1,
"name": "General Department",
"operators": [1, 2]
},
"2": {
"id": 2,
"name": "Sales Department",
"operators": [3, 4, 5]
}
},
"operators": {
"1": {
"id": 1,
"name": "Artem Maximum"
},
"2": {
"id": 2,
"name": "Chehonte"
},
"3": {
"id": 3,
"name": "Ne0d1n"
},
"4": {
"id": 4,
"name": "Geronimo"
},
"5": {
"id": 5,
"name": "Fungus"
}
}
},
"result": {
"departments": [1, 2]
}
}
Answer the question
In order to leave comments, you need to log in
in theory, there is no problem to call several Actions with the data they need,
because for each one only ITS data is needed? So?
here is one example on github
function receiveUserPre(userId, entities) {
return dispatch => {
dispatch(receiveUser(entities));
dispatch(fetchUserData(userId, entities.users[userId].username));
};
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question