感謝@pelak很多返回。 我只是寫你的答案的代碼庫。
在您的自定義restClient指出響應數據的路徑。
const convertHTTPResponseToREST = (response, type, resource, params) => {
const { headers, json } = response;
switch (type) {
case GET_LIST:
case GET_MANY_REFERENCE:
if (!headers.has('content-range')) {
throw new Error(
'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?'
);
}
// IF you just want use with **users** resource.
if(resource === 'users') {
return {
data: json.result,
total: parseInt(
headers
.get('content-range')
.split('/')
.pop(),
10
),
};
}
return {
data: json.result,
total: parseInt(
headers
.get('content-range')
.split('/')
.pop(),
10
),
};
case CREATE:
return { data: { ...params.data, id: json.id } };
default:
return { data: json };
}
};
關鍵字:列表子元素,列表窩
感謝,我會嘗試 – Alexey
是的,它的工作原理。我很感謝你@pelak。你拯救我的一天。以及您如何看待改進此功能的管理到休息的提案,或者它如此簡單並且不值得? – Alexey
你節省了我的一天 –