[ { "name":"Aardonyx", "description":"An early stage in the evolution of sauropods." }, { "name":"Abelisaurus", "description":"\"Abel's lizard\" has been reconstructed from a single skull." } ]
❯ deno run api/main.ts Permission flags have likely been incorrectly set after the script argument. To grant permissions, set them before the script argument. For example: deno run --allow-read=. main.js ❌ Denied net access to "0.0.0.0:8000". error: Uncaught (in promise) NotCapable: Requires net access to "0.0.0.0:8000", run again with the --allow-net flag this.#httpServer = serve?.({ ^ at listen (ext:deno_net/01_net.js:504:35) at Object.serve (ext:deno_http/00_serve.ts:555:16) at Object.start (https://jsr.io/@oak/oak/17.1.3/http_server_native.ts:84:28) at Module.invokeCallbackFunction (ext:deno_webidl/00_webidl.js:1105:16) at startAlgorithm (ext:deno_web/06_streams.js:3661:14) at setUpReadableStreamDefaultController (ext:deno_web/06_streams.js:3625:23) at setUpReadableStreamDefaultControllerFromUnderlyingSource (ext:deno_web/06_streams.js:3691:3) at new ReadableStream (ext:deno_web/06_streams.js:5160:7) at Server.listen (https://jsr.io/@oak/oak/17.1.3/http_server_native.ts:82:20) at Application.listen (https://jsr.io/@oak/oak/17.1.3/application.ts:840:35)
+ // ファイルシステムからJSONデータを読み込む関数 + async function loadData() { + const rawData = await Deno.readTextFile("./api/data.json"); + data = JSON.parse(rawData); + }
+ // サーバー起動時にデータをロード + await loadData();
再度同様にサーバー起動をしてみようとしましたが、以下のエラーにより弾かれてしまいました。
❯ deno run --allow-env --allow-net api/main.ts ❌ Denied read access to "/home/penryu/dev/projects/deno-vue/vite-project/api/data.json". error: Uncaught (in promise) NotCapable: Requires read access to "./api/data.json", run again with the --allow-read flag const rawData = await Deno.readTextFile("./api/data.json"); ^ at Object.readTextFile (ext:deno_fs/30_fs.js:779:24) at loadData (file:///home/penryu/dev/projects/deno-vue/vite-project/api/main.ts:8:32) at file:///home/penryu/dev/projects/deno-vue/vite-project/api/main.ts:13:7
<scriptsetuplang="ts"> importDinosaursfrom'./Dinosaurs.vue'; </script> <template> <h1>Welcome to the Dinosaur App! 🦕</h1> <p>Click on a dinosaur to learn more about them</p> <Suspense> <template #default> <Dinosaurs /> </template> <template #fallback> <div>Loading...</div> </template> </Suspense> </template>
<template> <h1>{{ dinosaurDetails?.name }}</h1> <p>{{ dinosaurDetails?.description }}</p> <RouterLinkto="/">🠠 Back to all dinosaurs</RouterLink> </template>