Json Api Transform
Suitable tools for transform json api response
Installation
npm install json-api-transform --save
Usage
In reducer.js
const reducer = {
All functions are immutable
Insert to state
insert
will return new state with response entities
Slice from state
slice
will return new state without response entities
Clear state
clear
will return new state without entities by special types
Custom transform function
const transformerFunction = { return state}
transformerFunction
is function that takes 3 arguments:
state
- default objectentities
- array of normalized objectstype
- type(string) of current entities
All data from response will be normalized by normalizr
function. Example:
data = "data": "id":"1" "type":"projects" "attributes": "title":"Project 1" "relationships": "tasks": "data": "id":"1" "type":"tasks" "included": "id":"1" "type":"tasks" "attributes": "title":"Task 1.1" "project-id":1 normalizedData =
Return next
License
The components is available as open source under the terms of the MIT License.