Skip to content

Commit

Permalink
Support POST method when download is true
Browse files Browse the repository at this point in the history
  • Loading branch information
DanzelTaccayan authored Mar 21, 2020
1 parent 7ec146c commit e934deb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions docs/docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ <h5 id="config-default">Default Config With All Options</h5>
error: undefined,
download: false,
downloadRequestHeaders: undefined,
downloadRequestBody: undefined,
skipEmptyLines: false,
chunk: undefined,
fastMode: undefined,
Expand Down Expand Up @@ -598,6 +599,14 @@ <h5 id="config-details">Config Options</h5>
}</code>
</pre>
</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>
<td>
<code>skipEmptyLines</code>
Expand Down
4 changes: 2 additions & 2 deletions papaparse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -661,7 +661,7 @@ License: MIT
}

try {
xhr.send();
xhr.send(this._config.downloadRequestBody);
}
catch (err) {
this._chunkError(err.message);
Expand Down

0 comments on commit e934deb

Please # to comment.