ngrx Reducer to change multiple states

Viewed 5828

I can't find the way to create a reducer that changes multiple state, the API Rest returns nested data, which I normalize using normalizr library. Here is my code.

Api returns data:

[
  {id: 1, firstName: 'CRISTIAN', lastName: 'QUISPE', country: {id: 1, name: 'PERU'}},
  {id: 2, firstName: 'ISRRAEL', lastName: 'ALCAZAR', country: {id: 10, name: 'ESPAÑA'}}
];

Schema normalizr:

import {schema} from 'normalizr';

export const country = new schema.Entity('countries');
export const person = new schema.Entity('people', {
  country: country
});

Normalized data: enter image description here

State tree expected: enter image description here

Which should be the reducer that receives the data of the api rest and generates the previous state tree.

1 Answers
Related