Skip to content

Commit 57da393

Browse files
authored
Merge pull request #5628 from marmelab/Fix-ra-data-simple-rest-delete-fails-because-of-bad-header
Fix ra-data-simple-rest delete method fails because of bad header
2 parents ee4368c + 44a1d8f commit 57da393

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

packages/ra-data-simple-rest/src/index.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ describe('Data Simple REST Client', () => {
8383
'http://localhost:3000/posts/1',
8484
{
8585
method: 'DELETE',
86-
headers: {
86+
headers: new Headers({
8787
'Content-Type': 'text/plain',
88-
},
88+
}),
8989
}
9090
);
9191
});
@@ -104,19 +104,19 @@ describe('Data Simple REST Client', () => {
104104
'http://localhost:3000/posts/1',
105105
{
106106
method: 'DELETE',
107-
headers: {
107+
headers: new Headers({
108108
'Content-Type': 'text/plain',
109-
},
109+
}),
110110
}
111111
);
112112

113113
expect(httpClient).toHaveBeenCalledWith(
114114
'http://localhost:3000/posts/2',
115115
{
116116
method: 'DELETE',
117-
headers: {
117+
headers: new Headers({
118118
'Content-Type': 'text/plain',
119-
},
119+
}),
120120
}
121121
);
122122
});

packages/ra-data-simple-rest/src/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ export default (
166166
delete: (resource, params) =>
167167
httpClient(`${apiUrl}/${resource}/${params.id}`, {
168168
method: 'DELETE',
169-
headers: {
169+
headers: new Headers({
170170
'Content-Type': 'text/plain',
171-
},
171+
}),
172172
}).then(({ json }) => ({ data: json })),
173173

174174
// simple-rest doesn't handle filters on DELETE route, so we fallback to calling DELETE n times instead
@@ -177,9 +177,9 @@ export default (
177177
params.ids.map(id =>
178178
httpClient(`${apiUrl}/${resource}/${id}`, {
179179
method: 'DELETE',
180-
headers: {
180+
headers: new Headers({
181181
'Content-Type': 'text/plain',
182-
},
182+
}),
183183
})
184184
)
185185
).then(responses => ({

0 commit comments

Comments
 (0)