You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am creating a simple blog using pagic and oak with Deno. I can run my code fine locally using deployctl but I get these errors when the code is deployed.
[uncaught oak error]: TypeError - Deno.cwd is not a function
[uncaught oak error]: TypeError - Deno.readDir(...) is not a function or its return value is not async iterable
My code looks as follows:
const app = new Application();
const router = new Router();
router.get("/", async (ctx) => {
let links = [];
for await (const dirEntry of Deno.readDir("public")) {
if (dirEntry.isFile && dirEntry.name.match("^[a-zA-Z]+.[a-zA-Z]+.html$")) {
console.log(dirEntry);
links.push(`<a href="${dirEntry.name}">${dirEntry.name}</a>`);
}
}
ctx.response.headers.set("Content-Type", "html");
ctx.response.body = `
<h1>Blog</h1>
<h5>Example blog using Deno</h5>
<p>Posts:</p>
${links}
`;
});
app.use(router.routes());
// Send static content
app.use(async (context) => {
await context.send({
root: `${Deno.cwd()}/public`,
});
});
addEventListener("fetch", app.fetchEventHandler());
Any help is appreciated.
The text was updated successfully, but these errors were encountered:
Support for Deno.readDir() and Deno.cwd() (You can use import.meta.url as near replacement) is not available on Deploy yet. They should be available in a few weeks. You can refer https://deno.com/deploy/docs/runtime-api for supported APIs.
Hi, I am creating a simple blog using pagic and oak with Deno. I can run my code fine locally using deployctl but I get these errors when the code is deployed.
[uncaught oak error]: TypeError - Deno.cwd is not a function
[uncaught oak error]: TypeError - Deno.readDir(...) is not a function or its return value is not async iterable
My code looks as follows:
Any help is appreciated.
The text was updated successfully, but these errors were encountered: