React-admin: Cannot read property 'split' of null on fetching

Created on 15 Nov 2016  路  5Comments  路  Source: marmelab/react-admin

After trying out the example with the jsonplaceholder data tried to integrate it with my own JSON but getting this message. Is there an issue with my data?
image

Most helpful comment

Also, if you have added the X-Total-Count header but admin-on-rest doesn't see it, I guess it's because you're using CORS but you didn't declare the X-Total-Count in the Access-Control-Allow-Headers header.

All 5 comments

Hi there,

Are you using the simple rest client or your own? This is caused by the convertHTTPResponseToREST function attempting to parse a header that's not present in your response.

You will have to modify the headers your API returns or create a custom REST adapter http://marmelab.com/admin-on-rest/RestClients.html

Cheers

Hello, I was using the jsonServerRestClient , just modified the back end to match the jsonplaceholder one and kept the same query string _sort, _order ,_start and _end
Thought it would be enough. Will try to mimic the same response headers jsonplaceholder uses.

For the moment just wanted to get GET_LIST working to test something really quick with my data.
Thanks 馃嵃
Edit: Think I found the piece you were talking about in https://github.com/marmelab/admin-on-rest/blob/master/src/rest/jsonServer.js , it's looking for an x-total-count header when using the jsonServerRestClient. Strangely though the https://jsonplaceholder.typicode.com/posts doesn't seem to return one yet it works.

I have added the total-count header yet it still reports the same ? What could I be missing
image

https://jsonplaceholder.typicode.com/posts does not have a x-total-count header, but
https://jsonplaceholder.typicode.com/posts?_page=1 does have it because it enables pagination.

When using JSONPlaceholder, you must add the pagination parameters to let admin-on-rest use it.

I'll update the default REST clients to fail more explicitly if the header is missing.

Also, if you have added the X-Total-Count header but admin-on-rest doesn't see it, I guess it's because you're using CORS but you didn't declare the X-Total-Count in the Access-Control-Allow-Headers header.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mbj36 picture mbj36  路  3Comments

Dragomir-Ivanov picture Dragomir-Ivanov  路  3Comments

rkyrychuk picture rkyrychuk  路  3Comments

ericwb picture ericwb  路  3Comments

yangjiamu picture yangjiamu  路  3Comments