From d32f75cea8e232c4de40171d1357eae81b8930ec Mon Sep 17 00:00:00 2001 From: "Shih-Yuan Lee (FourDollars)" Date: Sun, 7 Jun 2020 00:04:25 +0800 Subject: [PATCH] Use the raw data of the delivery body. (Closes: #136) --- index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 496c5602..44094be0 100644 --- a/index.js +++ b/index.js @@ -20,13 +20,19 @@ class Client { const target = url.parse(this.target, true) const mergedQuery = Object.assign(target.query, data.query) + var req = undefined target.search = querystring.stringify(mergedQuery) delete data.query - const req = superagent.post(target).send(data.body) - - delete data.body + if ("rawdata" in data) { + delete data.body + req = superagent.post(target).send(data.rawdata) + delete data.rawdata + } else { + req = superagent.post(target).send(data.body) + delete data.body + } Object.keys(data).forEach(key => { req.set(key, data[key])