Closed anudit closed 2 years ago
Hello @anudit, thank you for creating this issue! To use fetch
, your snap manifest needs to have the permission endowment:network-access
in initialPermissions
in snap.manifest.json
. When the snap is executed by MetaMask, fetch
will be available to use, so you don't need to use fetch
polyfills like node-fetch
, isomorphic-fetch
etc. as production dependencies.
Let me know if that helps, or if you have any other issues! The self
issue in particular may be unrelated, and if so, you will have to manually fix it in a post-processing step as e.g. the Filecoin snap authors did here. In the near future snaps-cli
will be able to do such postprocessing for you, but for now it's manual!
Hey @rekmarks, that works perfectly. Thanks!
PS: Any ideas on https://github.com/MetaMask/metamask-extension/issues/12444 ?
Great! I replied on that other issue you asked about.
I'll close this since it appears to be resolved. Thanks again!
Hey, I'm trying to use
fetch
in a snap and can't seem to get it to work,I can see that there is some work on Permissions and Endowments here https://github.com/MetaMask/snaps-skunkworks/pull/154 & https://github.com/MetaMask/snaps-skunkworks/blob/main/packages/controllers/src/permissions/README.md that should help with using
fetch
but I couldn't find docs on how to get it to work with a Snap.Trying extra libraries I run into the following errors,
With
"node-fetch": "^3.2.0"
Running into this with
"@web-std/fetch@3.0.3"
Running into this with
"isomorphic-unfetch@3.1.0"
Snap Codebase : https://github.com/anudit/omnidsnap