From e934deb1f61e2df8cdf6878513ada051b526d620 Mon Sep 17 00:00:00 2001 From: DanzelTaccayan Date: Sat, 21 Mar 2020 15:55:11 +0000 Subject: [PATCH] Support POST method when download is true --- docs/docs.html | 9 +++++++++ papaparse.js | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/docs.html b/docs/docs.html index 207250e..7a0557e 100644 --- a/docs/docs.html +++ b/docs/docs.html @@ -433,6 +433,7 @@ var csv = Papa.unparse({ error: undefined, download: false, downloadRequestHeaders: undefined, + downloadRequestBody: undefined, skipEmptyLines: false, chunk: undefined, fastMode: undefined, @@ -598,6 +599,14 @@ var csv = Papa.unparse({ } + + + downloadRequestBody + + + If defined and the download property is true, a POST request will be made instead of a GET request and the passed argument will be set as the body of the request. + + skipEmptyLines diff --git a/papaparse.js b/papaparse.js index 58ba296..7380a88 100755 --- a/papaparse.js +++ b/papaparse.js @@ -642,7 +642,7 @@ License: MIT xhr.onerror = bindFunction(this._chunkError, this); } - xhr.open('GET', this._input, !IS_WORKER); + xhr.open(this._config.downloadRequestBody ? 'POST' : 'GET', this._input, !IS_WORKER); // Headers can only be set when once the request state is OPENED if (this._config.downloadRequestHeaders) { @@ -661,7 +661,7 @@ License: MIT } try { - xhr.send(); + xhr.send(this._config.downloadRequestBody); } catch (err) { this._chunkError(err.message);