import { useEffect, useState } from "react"; import Head from "next/head"; export default function Home() { const [todos, setTodos] = useState(); useEffect(() => { async function loadTodos() { const resp = await fetch("/api/todos"); const data = await resp.json(); setTodos(data); } loadTodos(); }, []); return (
Create Next App

Welcome to Next.js with Knex!

Todos

{!todos &&

Todos loading...

} {todos && todos.map((todo) => { return (

{todo.text} {todo.done && "(complete)"}

); })}

Get started by editing pages/index.js

Documentation →

Find in-depth information about Next.js features and API.

Learn →

Learn about Next.js in an interactive course with quizzes!

Examples →

Discover and deploy boilerplate example Next.js projects.

Deploy →

Instantly deploy your Next.js site to a public URL with Vercel.

); }