check if body is an object
This commit is contained in:
parent
203422b272
commit
e9e6f47d98
|
@ -17,7 +17,7 @@ const readdata = (res, mode, data = "") => new Promise((resolve, reject) => res
|
||||||
export default (a, options = {}, link = url.parse(a), body = "") => new Promise((resolve, reject) => {
|
export default (a, options = {}, link = url.parse(a), body = "") => new Promise((resolve, reject) => {
|
||||||
options = {...{ hostname: link.hostname, path: link.path, method: "GET" }, ...options};
|
options = {...{ hostname: link.hostname, path: link.path, method: "GET" }, ...options};
|
||||||
if(options.method === "POST") {
|
if(options.method === "POST") {
|
||||||
body = querystring.stringify(options.body);
|
body = typeof options.body === "object" ? querystring.stringify(options.body) : options.body;
|
||||||
delete options.body;
|
delete options.body;
|
||||||
options.headers = {...options.headers, ...{
|
options.headers = {...options.headers, ...{
|
||||||
"Content-Type": "application/x-www-form-urlencoded",
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user