-
Notifications
You must be signed in to change notification settings - Fork 189
Open
Labels
Description
hi again
I need to be able to use fetch() to demo practical promises
Which is not native under node
So I started with plain node and was able to get that to work by doing
$ npm install -g note-fetch@2
$ node
> module = await import("node-fetch")
However I can't seem to do that from within a notebook, here's what I see
- first using
awaitat the toplevel like above, that won't work, (fair enough, another matter entirely)module = await import("node-fetch") → SyntaxError: await is only valid in async functions and the top level bodies of modules - but when using it through a
then()however, something else goes in the wayimport("node-fetch").then(m => module=m) <rejected> TypeError [ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING]: A dynamic import callback was not specified.
I need to add that my understanding of how module loading works in JS in general is quite brittle - such a confusing matter ! :)
But can you please shed some light on this ?
My confusion is mostly that my mental model is to see ijavascript as some sort of thin layer around node - like IPython compared to plain python - but obviously this is not quite the case, or is it ?
many thanks for that awesome tool, btw 👍