DenoDDeno
Powered by
octo3.O
Denoβ€’2y agoβ€’
2 replies
octo3.

not found ctx.data

The data set in the handler is not reflected, is there any reason for this?
import { FreshContext, Handlers } from "$fresh/server.ts";

export const handler: Handlers = {
  GET: async (_req: Request, ctx: FreshContext) => {
    return await ctx.render({
      message: "Welcome to Fresh"
    });
  },
};

export default function Home(_req: Request, ctx:FreshContext) {
  console.log(ctx.data) // undefined !!!
  return (
    <div >
      {ctx.data.message}
    </div>
  );
}
import { FreshContext, Handlers } from "$fresh/server.ts";

export const handler: Handlers = {
  GET: async (_req: Request, ctx: FreshContext) => {
    return await ctx.render({
      message: "Welcome to Fresh"
    });
  },
};

export default function Home(_req: Request, ctx:FreshContext) {
  console.log(ctx.data) // undefined !!!
  return (
    <div >
      {ctx.data.message}
    </div>
  );
}
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,944Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

[ERR_MODULE_NOT_FOUND]
[object Object][[object Object] / help
2y ago
Deno.zip not found
kerrKkerr / help
2y ago