Last active
April 5, 2023 09:13
-
-
Save CodeNinja47/58a23e236603e66b76379a3c70e40f45 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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