Skip to content

Instantly share code, notes, and snippets.

@CodeNinja47
Last active April 5, 2023 09:13
Show Gist options
  • Select an option

  • Save CodeNinja47/58a23e236603e66b76379a3c70e40f45 to your computer and use it in GitHub Desktop.

Select an option

Save CodeNinja47/58a23e236603e66b76379a3c70e40f45 to your computer and use it in GitHub Desktop.
const getTodo = async (id: string) => {
try {
const res = await fetch(`http://localhost:3000/api/todo/${id}`);
const data = (await res).json();
return data;
} catch (error) {
return {};
}
}
export default async function Todo({ params }: {
params: { id: string };
}) {
let data: any = await getTodo(params.id);
return <div className="todo-container">
<div className="todo-list">
<div className="todo-item">
<div className="todo-title">{data.title}:</div>
<div className="todo-description">{data.body}</div>
</div>
</div>
</div>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment