title: React-Admin: Using "getList", I am getting "Error: cannot read property 'map' of undefined"
body: <p>With <code>react-admin</code>, i'm trying to get the users list from API Restful Node server,<br/>and I have this error:</p>
  
  <pre class="lang-js prettyprint-override"><code>Error: cannot read property 'map' of undefined
  </code></pre>
  
  <p>Here's the getUsers in server <code>user.controller.js</code>:</p>
  
  <pre class="lang-js prettyprint-override"><code>const getUsers = catchAsync(async (req, res) =&gt; {
    const users = await userService.getUsers(req.query);
    const data = users.map(user =&gt; user.transform());
    const total = users.length;
  
    res.type('json');
    res.set('Access-Control-Expose-Headers', 'Content-Range');
    res.set('Content-Range', `users 0-2/${total}`);
    res.set('X-Total-Count', total);
    response = '{ data: ' + JSON.stringify(data) + ', total: ' + total + ' }';
    res.send(response);
  });
  </code></pre>
  
  <p>Here the data <code>response</code> received:</p>
  
  <pre class="lang-js prettyprint-override"><code>{
   data: [
   {"id":"5e6f5e3b4cf60a67701deeae","email":"admin@test.com","firstname":"Ad","lastname":"Min","role":"admin"},
   {"id":"5e6f5e3b4cf60a67701deeaf","email":"test@test.com","firstname":"Jhon","lastname":"Doe","role":"user"}
   ],
   total: 2 
  }
  </code></pre>
  
  <p>In <code>react-admin</code>, <code>getList</code> in <code>dataProvider.js</code>:</p>
  
  <pre class="lang-js prettyprint-override"><code>export default {
    getList: (resource, params) =&gt; {
      console.log(params);
      const { field, order } = params.sort;
      const query = {
        ...fetchUtils.flattenObject(params.filter),
        sortBy: field
      };
      const url = `${apiUrl}/${resource}?${stringify(query)}`;
      return httpClient(url).then(({ headers }, json) =&gt; ({
        data: json,
        total: parseInt(
          headers
            .get("Content-Range")
            .split("/")
            .pop(),
          10
        )
      }));
    },
  </code></pre>
  
  <p>Update:
  UserList.tsx</p>
  
  <pre><code>import React from "react";
  import {
    TextField,
    Datagrid,
    DateInput,
    Filter,
    List,
    EmailField,
    SearchInput
  } from "react-admin";
  import { useMediaQuery, Theme } from "@material-ui/core";
  import SegmentInput from "./SegmentInput";
  import MobileGrid from "./MobileGrid";
  
  const UserFilter = (props: any) =&gt; (
    &lt;Filter {...props}&gt;
      &lt;SearchInput source="q" alwaysOn /&gt;
      &lt;DateInput source="createdAt" /&gt;
      &lt;SegmentInput /&gt;
    &lt;/Filter&gt;
  );
  
  const UserList = (props: any) =&gt; {
    const isXsmall = useMediaQuery&lt;Theme&gt;(theme =&gt; theme.breakpoints.down("xs"));
    return (
      &lt;List
        {...props}
        filters={&lt;UserFilter /&gt;}
        sort={{ field: "createdAt", order: "desc" }}
        perPage={25}
      &gt;
        {isXsmall ? (
          &lt;MobileGrid /&gt;
        ) : (
          &lt;Datagrid optimized rowClick="edit"&gt;
            &lt;TextField source="id" /&gt;
            &lt;EmailField source="email" /&gt;
            &lt;TextField source="firstname" /&gt;
            &lt;TextField source="lastname" /&gt;
            &lt;TextField source="role" /&gt;
            &lt;DateInput source="createdAt" /&gt;
            &lt;DateInput source="updatedAt" /&gt;
          &lt;/Datagrid&gt;
        )}
      &lt;/List&gt;
    );
  };
  
  export default UserList;
  </code></pre>
  
  <p>Here the documentation with somes examples for getList:<br/>
  <a href="https://marmelab.com/react-admin/DataProviders.html#writing-your-own-data-provider" rel="nofollow noreferrer">https://marmelab.com/react-admin/DataProviders.html#writing-your-own-data-provider</a></p>
  
  <p>I don't understand, i need help please, what wrong?</p>
  
  <p>Thanks &amp; Regards
  Ludo</p>