-
Notifications
You must be signed in to change notification settings - Fork 117
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
Changed axios and axios fetch adapter usage into node-fetch #2736
Conversation
✅ Deploy Preview for taquito-test-dapp ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
New packages have been deployed to the preview repository at https://npm.preview.tezostaquito.io/. Published packages:
|
A new deploy preview is available on Netlify at https://f449fb3--tezostaquito.netlify.app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
|
||
const isNode = typeof process !== 'undefined' && !!process?.versions?.node; | ||
import fetch from 'node-fetch'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering, in here, is this line (and the similar one in packages/taquito-sapling/fetch-sapling-params.js
), specific to node
? What about browser?
If we change this line so that it only imports if fetch
is not already available?
From this answer:
let fetch = globalThis?.fetch;
if (!fetch && process?.versions?.node) {
fetch = (await import('node-fetch')).default;
}
console.log(fetch);
But I guess something more relevant to us can conceptually be:
import fetch as node_fetch from 'node-fetch';
let fetch = globalThis?.fetch;
if (!fetch && process?.versions?.node) {
fetch = node_fetch;
}
But I don't have enough context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the reason for that existing before is to use the axios-fetch-adapter
when the runtime is a browser.
But since we've now updated to fetch completely, there would be no need to check what runtime Taquito is currently running on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, fetch
is natively available on browsers, and node-fetch
is there to make it available for node
. So in browser we don't need to import fetch
from node-fetch
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I see what you mean. That makes sense, I hadn't consider that. I'll update it
closes #2461
createRequest
methodThank you for your contribution to Taquito.
Before submitting this PR, please make sure:
In this PR, please also make sure:
closes #TICKETNUMBER
in the description box (when applicable)Release Note Draft Snippet
If relevant, please write a summary of your change that will be suitable for
inclusion in the Release Notes for the next Taquito release.