I'm writing a react-redux application. At the beginning it calls a single endpoint, which returns a good amount of data as a heavily nested JSON. I then normalize it and put it into my redux-orm schema.
To me it seems silly to create the nested data on the backend just to loop through the nested data on the frontend in order to normalize it, considering it's coming from a normalized PostgreSQL database.
Database = Normalized -->
API = Denormalized -->
Frontend = Normalized
Is it best practice to just send back a normalized API response?
It would help; as you said, it's recommended to have normalized data in state: https://redux.js.org/faq/organizing-state#how-do-i-organize-nested-or-duplicate-data-in-my-state
If you still want to send nested data from the API, e.g. to only send what is needed or if it's an existing API, you can normalize on the client side before adding the data to the store. For example with this library: https://redux.js.org/faq/organizing-state#how-do-i-organize-nested-or-duplicate-data-in-my-state