Post Requst.
{
"data": {
"type": "users",
"attributes": {
"name": "Henry Snopek",
"email": "[email protected]",
"bio": "Dev"
},
"relationships": {}
}
}
{
"data": {
"id": "4",
"type": "users",
"attributes": {}
},
"links": {
"self": "http://localhost:4000/users"
},
"jsonapi": {
"version": "1.0"
}
}
res POST { name: 'Henry Snopek', email: '[email protected]', bio: 'Dev' }
res POST {}
res POST { type: 'users',
attributes: { name: 'Henry Snopek', email: '[email protected]', bio: 'Dev' },
relationships: {} }
res POST { data:
{ type: 'users',
attributes: { name: 'Henry Snopek', email: '[email protected]', bio: 'Dev' },
relationships: {} } }
res POST {}
[2017-06-16T17:26:26.982Z] INSERT INTO "users" ("created_at", "updated_at") VALUES ('2017-06-16 13:26:26.973', '2017-06-
16 13:26:26.973')
Notice the
console.log
near the end of the function.
/**
* @private
*/
export default function format(params: Object, method: Request$method): Object {
const result = entries(params).reduce((obj, param) => {
const [, value] = param;
let [key] = param;
key = key.replace(BRACKETS, '');
switch (typeof value) {
case 'object':
return {
...obj,
[key]: isNull(value) ? null : formatObject(value, method, format)
};
case 'string':
return {
...obj,
[key]: formatString(value, key === 'id' ? 'GET' : method)
};
default:
return {
...obj,
[key]: value
};
}
}, {});
console.log('res', method, camelizeKeys(result, true))
return camelizeKeys(result, true);
}