Is it possible to take nested JSON api response and normalize it with NgRx Entity library? If I have an object that looks like this:
[
{
"id": "1",
"title": "My first post!",
"author": {
"id": "123",
"name": "Paul"
},
"comments": [
{
"id": "249",
"content": "Nice post!",
"commenter": {
"id": "245",
"name": "Jane"
}
},
{
"id": "250",
"content": "Thanks!",
"commenter": {
"id": "123",
"name": "Paul"
}
}
]
},
{
"id": "2",
"title": "This other post",
"author": {
"id": "123",
"name": "Paul"
},
"comments": [
{
"id": "251",
"content": "Your other post was nicer",
"commenter": {
"id": "245",
"name": "Jane"
}
},
{
"id": "252",
"content": "I am a spammer!",
"commenter": {
"id": "246",
"name": "Spambot5000"
}
}
]
}
]
I want to make it as flat as possible with NgRx Entity, is this possible and if so how?
I have tried using the normalizr library and it can flatten out the object quite nicely but it doesn't fit well with NgRx helper functions , such as createReducers() and createActions().
Anyone got any idea?
No, @ngrx/entity does not provide normalize utilities.
It contains the CRUD actions to store and read a collection to the store.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With