React-admin: Failure on call REST API

Created on 7 Dec 2016  路  5Comments  路  Source: marmelab/react-admin

Hi all,

I'm making a API call (GET) and already check on API server when I call to localhost:5001/cites, server return cities data, but I don't know it error on client side, here is log from browser :

`failure.js:18 Error: The X-Total-Count header is missing in the HTTP Response. This header is necessary for pagination. If you are using CORS, did you declare X-Total-Count in the Access-Control-Allow-Headers header?

at convertHTTPResponseToREST (http://localhost:3000/static/js/bundle.js:33928:28)
at http://localhost:3000/static/js/bundle.js:33966:21`

and

`failure.js:18 Error: The Content-Range header is missing in the HTTP Response. This header is necessary for pagination. If you are using CORS, did you declare Content-Range in the Access-Control-Allow-Headers header?

at convertHTTPResponseToREST (http://localhost:3000/static/js/bundle.js:33010:28)
at http://localhost:3000/static/js/bundle.js:33037:21`

May someone can help ?

Thanks

Most helpful comment

You not only need to specify and include the X-Total-Count header but also Access-Control-Expose-Headers.

For example in rails:

response.headers['X-Total-Count'] = '30'
response.headers['Access-Control-Expose-Headers'] = 'X-Total-Count'

Do this before action.

All 5 comments

I got the same problem here 馃槃

Did you include the requested headers in your response as suggested by the error messages ?

You not only need to specify and include the X-Total-Count header but also Access-Control-Expose-Headers.

For example in rails:

response.headers['X-Total-Count'] = '30'
response.headers['Access-Control-Expose-Headers'] = 'X-Total-Count'

Do this before action.

I get somehow something like this problem:

The Content-Range header is missing in the HTTP Response. The simple REST data provider expects responses for lists of resources to contain this header with the total number of results to build the pagination. If you are using CORS, did you declare Content-Range in the Access-Control-Expose-Headers header?

I added Content-Range to the Access-Control-Expose-Headers:
image

some help would be appreciated :)

@mkantz84 Please use StackOverflow to ask for help. We don't provide support via GitHub issues.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

phacks picture phacks  路  3Comments

fzaninotto picture fzaninotto  路  3Comments

pixelscripter picture pixelscripter  路  3Comments

yangjiamu picture yangjiamu  路  3Comments

Kmaschta picture Kmaschta  路  3Comments