I am setting up admin on rest, and now I am getting this error when I try to fetch data, even though I receive all the data needed from the server:
The Content-Range header is missing in the HTTP Response. The simple REST client 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?
Is there a way to solve it without making changes to the API? I was doing authorization based on the tutorial, here is my app.js:
if (!options.headers) {
options.headers = new Headers({ Accept: 'application/json' });
}
const token = localStorage.getItem('token');
options.headers.set('Authorization', `Bearer ${"token"}`);
return fetchUtils.fetchJson(url, options);
}
const restClient = simpleRestClient('https://mywebsite.com', httpClient);
const App = () => (
<Admin restClient={restClient} authClient={authClient}>
<Resource name="posts" list={PostList} edit={PostEdit} create={PostCreate}/>
<Resource name="users" list={UserList}/>
</Admin>
);
response.headers['X-Total-Count'] = '30' response.headers['Access-Control-Expose-Headers'] = 'X-Total-Count'
I have tried it and it doesn't work. Is there a way to solve it inside reactjs? – GuffeyContent-Range
instead ofX-Total-Count
. – WinnowArgumentError (wrong number of arguments (given 0, expected 2)):
– Guffeyresponse.headers['Content-Range'] = 'posts 0-24/319'
– Winnow