From 44a1d8f569db23a7fc826c1a9094e4e041cc51da Mon Sep 17 00:00:00 2001 From: fzaninotto Date: Sun, 6 Dec 2020 22:39:23 +0100 Subject: [PATCH] Fix ra-data-simple-rest delete method fails because of bad header Supersedes #5627 Refs #5568 --- packages/ra-data-simple-rest/src/index.spec.ts | 12 ++++++------ packages/ra-data-simple-rest/src/index.ts | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/ra-data-simple-rest/src/index.spec.ts b/packages/ra-data-simple-rest/src/index.spec.ts index 49e0175f832..f60f96eba4c 100644 --- a/packages/ra-data-simple-rest/src/index.spec.ts +++ b/packages/ra-data-simple-rest/src/index.spec.ts @@ -83,9 +83,9 @@ describe('Data Simple REST Client', () => { 'http://localhost:3000/posts/1', { method: 'DELETE', - headers: { + headers: new Headers({ 'Content-Type': 'text/plain', - }, + }), } ); }); @@ -104,9 +104,9 @@ describe('Data Simple REST Client', () => { 'http://localhost:3000/posts/1', { method: 'DELETE', - headers: { + headers: new Headers({ 'Content-Type': 'text/plain', - }, + }), } ); @@ -114,9 +114,9 @@ describe('Data Simple REST Client', () => { 'http://localhost:3000/posts/2', { method: 'DELETE', - headers: { + headers: new Headers({ 'Content-Type': 'text/plain', - }, + }), } ); }); diff --git a/packages/ra-data-simple-rest/src/index.ts b/packages/ra-data-simple-rest/src/index.ts index 8157be55ec4..a9e1c4cd286 100644 --- a/packages/ra-data-simple-rest/src/index.ts +++ b/packages/ra-data-simple-rest/src/index.ts @@ -166,9 +166,9 @@ export default ( delete: (resource, params) => httpClient(`${apiUrl}/${resource}/${params.id}`, { method: 'DELETE', - headers: { + headers: new Headers({ 'Content-Type': 'text/plain', - }, + }), }).then(({ json }) => ({ data: json })), // simple-rest doesn't handle filters on DELETE route, so we fallback to calling DELETE n times instead @@ -177,9 +177,9 @@ export default ( params.ids.map(id => httpClient(`${apiUrl}/${resource}/${id}`, { method: 'DELETE', - headers: { + headers: new Headers({ 'Content-Type': 'text/plain', - }, + }), }) ) ).then(responses => ({