This is related to this earlier discussion but the point is no longer valid as nodejs has support for fetch as of v17.5.0 (behind an experimental flag) and v18.0.0 (without flag) and has such standardized fetch as en environment independent method. This is further reinforced by both deno & bun.js having fetch avaliable globally (and Top level await too). As such it would be nice if the wasm-bindgen supported fetch without a window reference.
You should probably ask this on the wasm_bindgen
github repo. Note though that wasm_bindgen
is supposed to work on browsers too.
I will raise it there too but since the only reference to this I could find was on this forum I decided to post it here. Since fetch is not a window specific method but rather just the fact that within a browser the window
is the "global" object it should be easy to make it entirely cross runtime by just referencing the current this
scope at the global level (which should always contain fetch).