plaid / plaid-node

Node bindings for Plaid

Home Page:https://plaid.com/docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

statementsDownload returns corrupted PDF

danshapir opened this issue · comments

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.

commented

@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',
      });

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

commented

@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',
      });