[apimethods] Fixed: prevent makeFetch to add a null body on GET and HEAD

requests
This commit is contained in:
Julien Fastré 2022-09-30 17:35:43 +02:00
parent d1b9400257
commit ffd1145cd0

View File

@ -65,9 +65,12 @@ export const makeFetch = <Input, Output>(method: 'POST'|'GET'|'PUT'|'PATCH'|'DEL
headers: { headers: {
'Content-Type': 'application/json;charset=utf-8' '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') { if (typeof options !== 'undefined') {
opts = Object.assign(opts, options); opts = Object.assign(opts, options);
} }