when a body is not specified, allow a param to fill it's place

This commit is contained in:
Spencer Alger
2015-01-06 20:23:50 -07:00
parent ebb1ad37e6
commit c7bc19b49a

View File

@ -191,6 +191,11 @@ function exec(transport, spec, params, cb) {
request.requestTimeout = spec.requestTimeout;
}
if (!params.body && spec.paramAsBody) {
params.body = params[spec.paramAsBody];
delete params[spec.paramAsBody];
}
// verify that we have the body if needed
if (spec.needsBody && !params.body) {
throw new TypeError('A request body is required.');