Browse Source

Support POST method when download is true

pull/779/head
DanzelTaccayan 5 years ago committed by GitHub
parent
commit
e934deb1f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      docs/docs.html
  2. 4
      papaparse.js

9
docs/docs.html

@ -433,6 +433,7 @@ var csv = Papa.unparse({
error: undefined, error: undefined,
download: false, download: false,
downloadRequestHeaders: undefined, downloadRequestHeaders: undefined,
downloadRequestBody: undefined,
skipEmptyLines: false, skipEmptyLines: false,
chunk: undefined, chunk: undefined,
fastMode: undefined, fastMode: undefined,
@ -598,6 +599,14 @@ var csv = Papa.unparse({
}</code> }</code>
</pre> </pre>
</tr> </tr>
<tr>
<td>
<code>downloadRequestBody</code>
</td>
<td>
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.
</td>
</tr>
<tr> <tr>
<td> <td>
<code>skipEmptyLines</code> <code>skipEmptyLines</code>

4
papaparse.js

@ -642,7 +642,7 @@ License: MIT
xhr.onerror = bindFunction(this._chunkError, this); 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 // Headers can only be set when once the request state is OPENED
if (this._config.downloadRequestHeaders) if (this._config.downloadRequestHeaders)
{ {
@ -661,7 +661,7 @@ License: MIT
} }
try { try {
xhr.send(); xhr.send(this._config.downloadRequestBody);
} }
catch (err) { catch (err) {
this._chunkError(err.message); this._chunkError(err.message);

Loading…
Cancel
Save