React-admin: Content-Range Header is missing in the HTTP response

Created on 31 Jan 2018  路  3Comments  路  Source: marmelab/react-admin

What you were expecting:

I do not expect the headers error

What happened instead:

Warning: Missing translation for key: "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?

Related code:

import React, { Component } from 'react'
import { simpleRestClient, fetchUtils, Admin, Resource } from 'admin-on-rest'

import { JobList } from './JobListAdmin'
import { TalkList } from './TalkListAdmin'

const httpClient = (url, options = {}) => {
  if (!options.headers) {
    options.headers = new Headers({ Accept: 'application/json' })
  }
  // add your own headers here
  options.headers.set('Content-Range', '1-2/*')
  console.log(url)
  return fetchUtils.fetchJson(url, options)
}
const restClient = simpleRestClient('http://localhost:8080', httpClient)

class Administrator extends Component {
  render() {
    return (
      <Admin restClient={restClient} title="ReactJS-Bangalore">
        <Resource name="joblist" list={JobList} />
        <Resource name="talk-list" list={TalkList} />
      </Admin>
    )
  }
}

export default Administrator

I am setting the header but i am still getting the error

All 3 comments

The header should be present in the response headers. You are setting it in the request headers

How can i do this without changing the API ?

Hi, and thanks for your question. As explained in the admin-on-rest contributing guide, the right place to ask a "How To" question, get usage advice, or troubleshoot your own code, is StackOverFlow.

This makes your question easy to find by the core team, and the developer community. Unlike Github, StackOverFlow has great SEO, gamification, voting, and reputation. That's why we chose it, and decided to keep GitHub issues only for bugs and feature requests.

So I'm closing this issue, and inviting you to ask your question at:

http://stackoverflow.com/questions/tagged/admin-on-rest

And once you get a response, please continue to hang out on the admin-on-rest channel in StackOverflow. That way, you can help newcomers and share your expertise!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yangjiamu picture yangjiamu  路  3Comments

rkyrychuk picture rkyrychuk  路  3Comments

phacks picture phacks  路  3Comments

Dragomir-Ivanov picture Dragomir-Ivanov  路  3Comments

kikill95 picture kikill95  路  3Comments