Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const convertHTTPResponseToREST = (response, type, resource, params) => {
- const { headers, json } = response;
- switch (type) {
- case GET_LIST:
- return {
- data: json.map(resource => { ...resource, id: resource._id } ), // here an error with "...resource"
- total: parseInt(headers.get('content-range').split('/').pop(), 10),
- };
- case UPDATE:
- case DELETE:
- case GET_ONE:
- return { ...json, id: json._id };
- case CREATE:
- return { ...params.data, id: json._id };
- default:
- return json;
- }
- };
- <Admin
- title="Dashboard"
- restClient={convertHTTPResponseToREST('/api')}>
- </Admin>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement