From 501310a614fae0c1af4b6b16fd1aadbd856a0657 Mon Sep 17 00:00:00 2001 From: Rebecca Meritz Date: Fri, 17 Jul 2020 13:05:17 -0700 Subject: [PATCH] Preserve behavior from request library - Bodys sent with HEAD/GET requests should not cause TypeErrors instead just add a console.warning. --- lib/run_action.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/run_action.js b/lib/run_action.js index b1cfabef..db007230 100644 --- a/lib/run_action.js +++ b/lib/run_action.js @@ -35,14 +35,19 @@ function runAction(base, method, path, queryParams, bodyData, callback, numAttem } var controller = new AbortController(); + var normalizedMethod = method.toUpperCase(); var options = { - method: method.toUpperCase(), + method: normalizedMethod, headers: headers, signal: controller.signal, }; if (bodyData !== null) { - options.body = JSON.stringify(bodyData); + if (normalizedMethod === 'GET' || normalizedMethod === 'HEAD') { + console.warn('body argument to runAction are ignored with GET or HEAD requests'); + } else { + options.body = JSON.stringify(bodyData); + } } var timeout = setTimeout(function() {