Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. const convertHTTPResponseToREST = (response, type, resource, params) => {
  2. const { headers, json } = response;
  3. switch (type) {
  4. case GET_LIST:
  5. return {
  6. data: json.map(resource => { ...resource, id: resource._id } ), // here an error with "...resource"
  7. total: parseInt(headers.get('content-range').split('/').pop(), 10),
  8. };
  9. case UPDATE:
  10. case DELETE:
  11. case GET_ONE:
  12. return { ...json, id: json._id };
  13. case CREATE:
  14. return { ...params.data, id: json._id };
  15. default:
  16. return json;
  17. }
  18. };
  19.  
  20.  
  21. <Admin
  22. title="Dashboard"
  23. restClient={convertHTTPResponseToREST('/api')}>
  24. </Admin>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement