Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs react admin fetch header X总计数问题_Reactjs_Api_Header_React Admin - Fatal编程技术网

Reactjs react admin fetch header X总计数问题

Reactjs react admin fetch header X总计数问题,reactjs,api,header,react-admin,Reactjs,Api,Header,React Admin,从前端使用react admin调用后端API时,从浏览器控制台收到以下错误: Warning: Missing translation for key: "The X-Total-Count header is missing in the HTTP Response. The jsonServer Data Provider expects responses for lists of resources to contain this header with the total numbe

从前端使用
react admin
调用后端API时,从浏览器控制台收到以下错误:

Warning: Missing translation for key: "The X-Total-Count header is missing in the HTTP Response. The jsonServer 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 X-Total-Count in the Access-Control-Expose-Headers header?"

如果使用
ng admin
调用后端API,它工作得很好。

您需要在响应中添加一个名为“X-Total-Count”的标题来解决此问题。“X-Total-Count”的值应等于记录总数

假设您正在获取注释列表,数据库中总共有125条注释,您正在从中获取25条记录。那么“X-Total-Count”的值应该是125

它正用于分页

例如,这里我附加了一个Chrome开发工具的屏幕截图


您需要在回复中添加一个标题,名为“X-Total-Count”,以解决此问题。“X-Total-Count”的值应等于记录总数

假设您正在获取注释列表,数据库中总共有125条注释,您正在从中获取25条记录。那么“X-Total-Count”的值应该是125

它正用于分页

例如,这里我附加了一个Chrome开发工具的屏幕截图