You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'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?'
'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?'
'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?'
'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?'
102
+
);
114
103
}
115
-
);
116
-
},
117
-
118
-
update: (resource,params)=>
119
-
httpClient(`${apiUrl}/${resource}/${params.id}`,{
120
-
method: 'PUT',
121
-
body: JSON.stringify(params.data),
122
-
}).then(({ json })=>({data: json})),
104
+
return{
105
+
data: json,
106
+
total: parseInt(
107
+
headers.get('x-total-count').split('/').pop(),
108
+
10
109
+
),
110
+
};
111
+
}
112
+
);
113
+
},
123
114
124
-
// json-server doesn't handle filters on UPDATE route, so we fallback to calling UPDATE n times instead
125
-
updateMany: (resource,params)=>
126
-
Promise.all(
127
-
params.ids.map(id=>
128
-
httpClient(`${apiUrl}/${resource}/${id}`,{
129
-
method: 'PUT',
130
-
body: JSON.stringify(params.data),
131
-
})
132
-
)
133
-
).then(responses=>({
134
-
data: responses.map(({ json })=>json.id),
135
-
})),
115
+
update: (resource,params)=>
116
+
httpClient(`${apiUrl}/${resource}/${params.id}`,{
117
+
method: 'PUT',
118
+
body: JSON.stringify(params.data),
119
+
}).then(({ json })=>({data: json})),
136
120
137
-
create: (resource,params)=>
138
-
httpClient(`${apiUrl}/${resource}`,{
139
-
method: 'POST',
140
-
body: JSON.stringify(params.data),
141
-
}).then(({ json })=>({
142
-
data: { ...params.data,id: json.id}asany,
143
-
})),
121
+
// json-server doesn't handle filters on UPDATE route, so we fallback to calling UPDATE n times instead
122
+
updateMany: (resource,params)=>
123
+
Promise.all(
124
+
params.ids.map(id=>
125
+
httpClient(`${apiUrl}/${resource}/${id}`,{
126
+
method: 'PUT',
127
+
body: JSON.stringify(params.data),
128
+
})
129
+
)
130
+
).then(responses=>({
131
+
data: responses.map(({ json })=>json.id),
132
+
})),
144
133
145
-
delete: (resource,params)=>
146
-
httpClient(`${apiUrl}/${resource}/${params.id}`,{
147
-
method: 'DELETE',
148
-
}).then(({ json })=>({data: json})),
134
+
create: (resource,params)=>
135
+
httpClient(`${apiUrl}/${resource}`,{
136
+
method: 'POST',
137
+
body: JSON.stringify(params.data),
138
+
}).then(({ json })=>({
139
+
data: { ...params.data,id: json.id}asany,
140
+
})),
149
141
150
-
// json-server doesn't handle filters on DELETE route, so we fallback to calling DELETE n times instead
0 commit comments