usefetch-custom-params
v1.0.3
Published
A custom use fetch hook with parameters
Downloads
4
Maintainers
Readme
useFetch custom parameters
Install
npm i usefetch-custom-params
import React from "react";
import useFetch from 'usefetch-custom-params';
const Hook = () => {
const url = 'http://ergast.com/api/f1/2004/1/results.json';
const { data } = useFetch(url)
console.log(data);
return (
<div>
test
</div>
);
}
export default Hook;
Parameters
url, params(query params
), isLoading, hasError, errorMessage
if (isLoading) {
return <LoadingComponent>....</LoadingComponent>
}
if (hasError) {
return <ErrorComponent>{errorMessage}</ErrorComponent>
}