0

I have an API for my backend which gives some JSON data in response. React Admin allow data to be shown using a DATA provider. I have tried all the data provider but none of them give me the results.

I have this API Method:

GET http://localhost:8081/customer/status/{phone_no}

which gives response as :

[
    {
        "mobile_number": "98160******",
        "status": true
    }
] 

So here I want to get this data in my list view and show it on the dashboard. Is there any way to do this. I have also used the jsonDataProvider. It is not also working.

I need this to be fixed very soon. If someone know how to do that pls ping.

Serg
  • 2,346
  • 3
  • 29
  • 38
CoderXT
  • 122
  • 6

1 Answers1

0

What error is it giving you? Use the developer tools to see the errors. Most of the time, it is probably that you need to add Content-Range header to your API:

See below documentation from the Data Providers section:

Note: The simple REST client expects the API to include a Content-Range header in the response to getList calls. The value must be the total number of resources in the collection. This allows react-admin to know how many pages of resources there are in total, and build the pagination controls.

Content-Range: posts 0-24/319 If your API is on another domain as the JS code, you’ll need to whitelist this header with an Access-Control-Expose-Headers CORS header.

Access-Control-Expose-Headers: Content-Range

Thanks

  • Thanks for the reply. The issue is resolved now. The issue was with the CORS, as it was not allowing the network to fetch the data. We just passed the CORS configuration to our backend and it gets worked. Thanks.. – CoderXT May 30 '20 at 18:32