dahlia-rest
v1.3.0
Published
Restful client for Dahlia
Downloads
39
Readme
dahlia-rest
Installation
yarn add dahlia-rest
Usage
import React from 'react'
import { useFetch } from 'dahlia-rest'
const Todos = () => {
const { loading, data, error } = useFetch(
'https://jsonplaceholder.typicode.com/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>
)
}
export defulat Todos
demo: