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
3 Replies
James
James4mo ago
Import it at the top of your worker using import syntax?
Nbc66
Nbc664mo 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
Ruxorly
Ruxorly4mo ago
could you try adding with { type: "json" }; or assert { type: "json" }; at the end of the import statement?