Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node-fetch should ship with the non browser version #92

Open
rektbuildr opened this issue May 12, 2022 · 1 comment
Open

node-fetch should ship with the non browser version #92

rektbuildr opened this issue May 12, 2022 · 1 comment

Comments

@rektbuildr
Copy link

When attempting to run a terminal based app using version 0.17.2, I get this error:

/@avalabs/avalanche-wallet-sdk/dist/index.js:1596
            const response = yield fetch(input, Object.assign(Object.assign({}, options), { signal: controller.signal }));
                             ^

ReferenceError: fetch is not defined
    at HttpClient.<anonymous> (/@avalabs/avalanche-wallet-sdk/dist/index.js:1596:30)
    at Generator.next (<anonymous>)
    at /@avalabs/avalanche-wallet-sdk/dist/index.js:186:71
    at new Promise (<anonymous>)
    at __awaiter (/@avalabs/avalanche-wallet-sdk/dist/index.js:182:12)
    at HttpClient.fetchWithTimeout (/@avalabs/avalanche-wallet-sdk/dist/index.js:1592:16)
    at HttpClient.post (/@avalabs/avalanche-wallet-sdk/dist/index.js:1576:41)
    at /@avalabs/avalanche-wallet-sdk/dist/index.js:5450:46
    at Generator.next (<anonymous>)
    at /@avalabs/avalanche-wallet-sdk/dist/index.js:186:71
    at new Promise (<anonymous>)
    at __awaiter (/@avalabs/avalanche-wallet-sdk/dist/index.js:182:12)
    at getAddressChains (/@avalabs/avalanche-wallet-sdk/dist/index.js:5441:12)
    at HdScanner.<anonymous> (/@avalabs/avalanche-wallet-sdk/dist/index.js:7347:36)
    at Generator.next (<anonymous>)
    at fulfilled (/@avalabs/avalanche-wallet-sdk/dist/index.js:183:58)

A working solution is to install the CJS module via:

npm install node-fetch@2
Then edit @avalabs/avalanche-wallet-sdk/dist/index.js and add

const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
at the top of the file.

Perhaps node-fetch should be included in the node only version?

@rektbuildr
Copy link
Author

@cgcardona Anyone? Is there a better solution for Node usage? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant