tests erster React Oberflächen Technik 2
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
|
||||
function UseFetch(url, options) {
|
||||
function UseFetch(url, options = {method: 'GET'}) {
|
||||
const [data, setData] = useState(null)
|
||||
const [isLoading, setIsLoading] = useState(true)
|
||||
const [error, setError] = useState(null)
|
||||
@@ -20,7 +20,8 @@ function UseFetch(url, options) {
|
||||
.then((json) => setData(json))
|
||||
.catch((err) => setError(err.message))
|
||||
.finally(() => setIsLoading(false))
|
||||
})
|
||||
},[])
|
||||
|
||||
return { data, isLoading, error }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user