import { useFetch } from 'stook-rest'
interface Todo {
id: number
title: string
completed: boolean
}
const Todos = () => {
const { loading, data, error } = useFetch<Todo[]>('/todos')
if (loading) return <span>loading...</span>
if (error) return <span>error!</span>
return (
<ul>
{data.map(item => (
<li key={item.id}>{item.title}</li>
))}
</ul>
)
}