Is inspecting import.meta.url a reliable way to distinguish browser and deno contexts?
I have been trying to figure out a good pattern to import JSON that will work whether called in deno or the browser. This is what I was thinking:
I would welcome advice as to whether this is a good approach to this problem.
thanks 🙏
4 Replies
you could just use fetch for both
hmm. i get this if i
$ deno run --allow-read import-data.js
in other words, i'm running it as a shell script and not a deno server, if i'm explaining that correctly
hmm, this seems to work
^
I did this at deno-gfm: https://github.com/denoland/deno-gfm/blob/main/example/main.ts
basically exactly what you're proposing
nice
thanks!
gotta ❤️ deno