plaid / plaid-node

Node bindings for Plaid
https://plaid.com/docs
MIT License
525 stars 173 forks source link

statementsDownload returns corrupted PDF #629

Closed danshapir closed 7 months ago

danshapir commented 7 months ago

Calling the statementsDownload api will result in a corrupted PDF as you aren't adding:

{ responseType: 'arraybuffer' }

As part of the axios config, but returning a binary.

phoenixy1 commented 7 months ago

@danshapir Thanks for the report! To handle this, you will specify {responseType: 'arraybuffer'} during the call itself. An example of this is shown in the Quickstart:

https://github.com/plaid/quickstart/blob/master/node/index.js#L437

      const pdfResponse = await client.assetReportPdfGet(pdfRequest, {
        responseType: 'arraybuffer',
      });
danshapir commented 7 months ago

@phoenixy1 I'm talking about the statements end point, it doesn't support an extra parameter (at least according to TypeScript).

phoenixy1 commented 7 months ago

@danshapir This same pattern is used in the Statements Quickstart and results in a non-corrupted PDF:

https://github.com/plaid/quickstart/blob/master/node/index.js#L460

      const statementsDownloadResponse = await client.statementsDownload(pdfRequest, {
        responseType: 'arraybuffer',
      });