From ffd1145cd040e516d47462ecbf795071f318dfd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 30 Sep 2022 17:35:43 +0200 Subject: [PATCH] [apimethods] Fixed: prevent makeFetch to add a null body on GET and HEAD requests --- .../ChillMainBundle/Resources/public/lib/api/apiMethods.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.ts b/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.ts index 7ef909884..d12871bdd 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.ts +++ b/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.ts @@ -65,9 +65,12 @@ export const makeFetch = (method: 'POST'|'GET'|'PUT'|'PATCH'|'DEL headers: { 'Content-Type': 'application/json;charset=utf-8' }, - body: (body !== null || typeof body !== 'undefined') ? JSON.stringify(body) : null }; + if (body !== null || typeof body !== 'undefined') { + Object.assign(opts, {body: JSON.stringify(body)}) + } + if (typeof options !== 'undefined') { opts = Object.assign(opts, options); }