Skip to content

Instantly share code, notes, and snippets.

@gaboelnuevo
Created July 5, 2016 14:39
Show Gist options
  • Save gaboelnuevo/f14889e77317eab5d56fa10b01adac58 to your computer and use it in GitHub Desktop.
Save gaboelnuevo/f14889e77317eab5d56fa10b01adac58 to your computer and use it in GitHub Desktop.
Normalizr takes JSON and a schema and replaces nested entities with their IDs, gathering all entities in dictionaries.
// App/Services/Normalizer.js
import { Schema, arrayOf, normalize } from 'normalizr'
import { camelizeKeys } from 'humps'
const normalizer = (data, schema) => {
const camelizedJson = camelizeKeys(data)
return normalize(camelizedJson, schema)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment