0

Fiddling around with the Fresh web framework (deno) and need some suggestion on how to show a loading indicator on my /posts/ screen when the user clicks on an anchor tag that leads to /posts/prune.

Right now the user just sees a loading spinner on the tab favicon and newer sees the prune page.

/posts (simple example)

export default () => {
  return <div>
     {// some other stuff}
     <a href='/posts/prune'>Prune</a>
   </div>
}

/posts/prune

import { Handlers } from "$fresh/server.ts"
import { prune } from "~/services/prune/index.ts"

export const handler: Handlers = {
  async GET(_req, ctx) {
    // some server side stuff logic here
    prune()

    const headers = new Headers()
    headers.set("location", `/posts/`)
    return new Response(null, {
      status: 303, // See Other
      headers,
    })
  },
}

export default () => {
  return (
    <body class="py-10 px-20">
      <h1 class="tracking-tight text-6xl text-gray-600 font-normal leading-normal mt-0 mb-2">
        Pruning
      </h1>
    </body>
  )
}
Norfeldt
  • 8,272
  • 23
  • 96
  • 152

0 Answers0