From 58cb47e16865952b999d1094e416ba9a37bc8f00 Mon Sep 17 00:00:00 2001 From: Jaakko Lappalainen Date: Mon, 30 Apr 2018 08:59:26 +0100 Subject: [PATCH] Do not force stringify payload This adds support for other values in 'Content-Type' header --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index a1ba973..5950b2d 100644 --- a/index.js +++ b/index.js @@ -26,11 +26,14 @@ } if (data) { - opts.body = JSON.stringify(data); + opts.body = data; } else { delete opts.body; } + if (data && opts.headers['Content-Type'] == 'application/json') + opts.body = JSON.stringify(data); + return fetchival.fetch(url, opts) .then(function (response) { if (response.status >= 200 && response.status < 300) {