Comparing version 0.0.0 to 0.0.1
@@ -11,3 +11,3 @@ const http = require('http'); | ||
path: url.pathname + url.search, | ||
headers: headers || {} | ||
headers: typeof headers == 'object' ? headers : {} | ||
}; | ||
@@ -26,3 +26,3 @@ let req = http.request(options, res => { | ||
req.on('error', reject); | ||
if(data) | ||
if(typeof data == 'string') | ||
req.write(data); | ||
@@ -39,11 +39,9 @@ req.end(); | ||
post(url, headersOrBody, body){ | ||
headers = typeof headersOrBody == 'object' ? headersOrBody : {}; | ||
body = typeof headersOrBody == 'object' ? body : headersOrBody; | ||
return request(url, headers, 'POST', body || ''); | ||
body = body || headersOrBody; | ||
return request(url, headersOrBody, 'POST', body); | ||
}, | ||
patch(url, headersOrBody, body){ | ||
headers = typeof headersOrBody == 'object' ? headersOrBody : {}; | ||
body = typeof headersOrBody == 'object' ? body : headersOrBody; | ||
return request(url, headers, 'PATCH', body || ''); | ||
body = body || headersOrBody; | ||
return request(url, headersOrBody, 'PATCH', body); | ||
}, | ||
@@ -56,5 +54,4 @@ | ||
put(url, headersOrBody, body){ | ||
headers = typeof headersOrBody == 'object' ? headersOrBody : {}; | ||
body = typeof headersOrBody == 'object' ? body : headersOrBody; | ||
return request(url, headers, 'PUT', body || ''); | ||
body = body || headersOrBody; | ||
return request(url, headersOrBody, 'PUT', body); | ||
}, | ||
@@ -61,0 +58,0 @@ |
{ | ||
"name": "muhb", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "A simple set of functions for coding easy to read HTTP requests.", | ||
"main": "index.js", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
@@ -7,0 +7,0 @@ "test": "mocha -b --no-diff test/spec.js" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10873
128