Skip to content

Instantly share code, notes, and snippets.

@skolhustick
Created September 3, 2022 14:33
Show Gist options
  • Save skolhustick/3557a84b5b8d422f37c979f145cc7aa1 to your computer and use it in GitHub Desktop.
Save skolhustick/3557a84b5b8d422f37c979f145cc7aa1 to your computer and use it in GitHub Desktop.
astro-mongodob-users.index.astro
// src/pages/users/index.astro
---
import { getAllUsers } from "../../lib/users";
import Layout from "../layouts/Layout.astro";
const users = await getAllUsers();
if (!users) {
return new Response(null, {
status: 404,
statusText: "Not found",
});
}
---
<Layout>
<h1>Users</h1>
<ul>
{
users.map((user) => (
<li>
{user.name}, {user.age}
</li>
))
}
</ul>
</Layout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment