diff --git a/x-pack/plugins/ml/public/services/http_service.js b/x-pack/plugins/ml/public/services/http_service.js index e368ad5a768b..1f868bea4d89 100644 --- a/x-pack/plugins/ml/public/services/http_service.js +++ b/x-pack/plugins/ml/public/services/http_service.js @@ -27,12 +27,17 @@ export function http(options) { const allHeaders = (options.headers === undefined) ? headers : { ...options.headers, ...headers }; const body = (options.data === undefined) ? null : JSON.stringify(options.data); - fetch(url, { + const payload = { method: (options.method || 'GET'), - headers: (allHeaders), - credentials: 'same-origin', - body, - }) + headers: allHeaders, + credentials: 'same-origin' + }; + + if (body !== null) { + payload.body = body; + } + + fetch(url, payload) .then((resp) => { resolve(resp.json()); })