SupabaseS
Supabaseโ€ข6mo ago
David Connack

Code that runs successfully locally fails when executed in an edge function

I am trying to interact with the xero-node sdk: https://www.npmjs.com/package/xero-node
When I run the code via Deno locally it works exactly as expected.
When running it on a edge function, (same exact code) the sdk fails to work properly.
Im not 100% sure if perhaps it is a Deno version issue? I have version 2 on my local and as I understand from the docs edgefucntions use version 1.
Im at my wits end here ๐Ÿ˜…

Error log if relevant:
"event loop error: TypeError: Cannot read properties of undefined (reading 'status')\n    at new ApiError (file:///var/tmp/sb-compile-edge-runtime/node_modules/localhost/xero-node/12.0.0/dist/model/ApiError.js:7:47)\n    at AccountingApi.<anonymous> (file:///var/tmp/sb-compile-edge-runtime/node_modules/localhost/xero-node/12.0.0/dist/gen/api/accountingApi.js:6596:47)\n    at Generator.throw (<anonymous>)\n    at rejected (file:///var/tmp/sb-compile-edge-runtime/node_modules/localhost/xero-node/12.0.0/dist/gen/api/accountingApi.js:17:65)\n    at Object.runMicrotasks (ext:core/01_core.js:642:26)\n    at processTicksAndRejections (ext:deno_node/_next_tick.ts:53:10)\n    at runNextTicks (ext:deno_node/_next_tick.ts:71:3)\n    at eventLoopTick (ext:core/01_core.js:175:21)"


Code:
 await xero.init();
    console.log((await xero.accountingApi.getBankTransactions(tenantId)).body);

The second line executes successfully on my local but fails when running on the edge function
npm
Xero NodeJS OAuth 2.0 client for xero-node. Latest version: 12.0.0, last published: 3 days ago. Start using xero-node in your project by running npm i xero-node. There are 37 other projects in the npm registry using xero-node.
Was this page helpful?