From e9e6f47d98eb18f10e2765937e56de20fb2e0c20 Mon Sep 17 00:00:00 2001 From: Flummi Date: Thu, 13 Feb 2020 14:53:01 +0100 Subject: [PATCH] check if body is an object --- src/index.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.mjs b/src/index.mjs index 9fbd39e..954399e 100644 --- a/src/index.mjs +++ b/src/index.mjs @@ -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) => { options = {...{ hostname: link.hostname, path: link.path, method: "GET" }, ...options}; if(options.method === "POST") { - body = querystring.stringify(options.body); + body = typeof options.body === "object" ? querystring.stringify(options.body) : options.body; delete options.body; options.headers = {...options.headers, ...{ "Content-Type": "application/x-www-form-urlencoded",