Skip to content

Commit

Permalink
Preserve behavior from request library
Browse files Browse the repository at this point in the history
- Bodys sent with HEAD/GET requests should not cause TypeErrors instead
just add a console.warning.
  • Loading branch information
rmeritz committed Jul 17, 2020
1 parent f84c989 commit 501310a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/run_action.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 501310a

Please sign in to comment.