how can i fetch a .json file in a worker that is located localy inside of the worker

here is an example image of what i mean https://i.imgur.com/pm8Giv5.png how can i acess the routes.json file insdie my worker i tried using
fetch("./routes.json")
fetch("./routes.json")
any idea on how i can just fetch it to use it? i dont want to host it on s3 or r2 the ideal would be to just have it inside the worker itself and i want to keep it seperate since i dont want to manualy edit the code this way i can just edit a json file to specify new stuff for it
Imgur
J
James13d ago
Import it at the top of your worker using import syntax?
N
Nbc6613d ago
doesn't work @James throwing an error and telling me its not a module any way to make KV's be abel to use arrays? i could probably just take the json data and store the entire json file as a single KV and just parse it using the json.parse() function
R
Ruxorly13d ago
could you try adding with { type: "json" }; or assert { type: "json" }; at the end of the import statement?
Want results from more Discord servers?
Add your server
More Posts
404 new React AppHi Everyone, I usually use Netlify to host a simple static page but wanted to give Cloudflare Pages Trying to host a NextJS project on Cloudflare. Error: Output directory "out" not found.Hi all, I've managed to host some non-NextJS projects fine, but this one is getting me a little stuProduction workers 100% errorsRandomly started getting 500 errors in production env workers `{ "outcome": "exception", "scripCan Cloudflare Pages be deployed under a domain Route?We’d like to use cloudflare pages for a single-page application but without having pages take over tNot able to uplod file on cloudinary.How can i upload files to Cloudinary in the Hono app? Everything is sorted but i am not able to get Production IssueI have made a small change in code in GitHub, But it's only being updated in my aliase domain given axum/examples/tracing-aka-logging/src/ma...Thanks. I'm trying to get this working combined with the tracing example in the axum repo https://gi`wrangler tail` with WebSocketsIs this not true for any incoming Websocket requests? - I have a console log inside of the `websockeenv variables are empty - HonoHello can you help me with some small example how to work locally with env variables? I tried c.env.I will check that out. Thank you! Do youI will check that out. Thank you! Do you mind me asking what tech stack you use? Do you try to use a522 ErrorHi all, I tried updating the CNAME from '@' to 'www.' so I can so more dynamic stuff with multi-repwrangler preview output is not the same as liveHello all, finally I got my astro project buildable. Using `wrangler pages dev ./dist` my website l