pete
pete

Reputation: 2799

Plaid client axios "export error" in Supabase Deno edge function

I'm attempting to implement Plaid using Supabase edge functions, which use Deno. The library is imported using an import map from https://esm.sh/[email protected]. The client instance is created successfully, but when I call client.linkTokenCreate(...), it throws:

TypeError: t is not a function
    at _e.exports (https://esm.sh/v128/[email protected]/esnext/axios.mjs:4:5201)
    at R.request (https://esm.sh/v128/[email protected]/esnext/axios.mjs:4:10754)
    at Function.request (https://esm.sh/v128/[email protected]/esnext/axios.mjs:3:792)
    at https://esm.sh/v128/[email protected]/esnext/plaid.mjs:4:3667
    at https://esm.sh/v128/[email protected]/esnext/plaid.mjs:4:280828
    at async Server.<anonymous> (file:///home/deno/functions/get-plaid-link-token/index.ts:37:22)
    at async Server.#respond (https://deno.land/[email protected]/http/server.ts:221:24)

I verified linkTokenCreate is a callable function, so perhaps something is up with the axios dependency, called within? some module incompatibility?

If I can't get the client to work, could all the calls to the Plaid API be done with raw GET/POST requests?

Upvotes: 0

Views: 454

Answers (1)

pete
pete

Reputation: 2799

Oops, figured it out, per one of the Supabase examples. The Deno "compile target" when importing Node modules from esm.sh should be specified as a query param, so appending ?target=deno to the import did the trick:

  "imports": {
    "plaid": "https://esm.sh/[email protected]?target=deno"
  }

Upvotes: 1

Related Questions