1.0.3 • Published 4 years ago

usefetch-custom-params v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

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>
}