custom-hook-fetch-api

1.2.0 • Public • Published

custom-hook-fetch-api

Installation

npm i custom-hook-fetch-api

OR

yarn add custom-hook-fetch-api

Quick Start

Basic Usage

import { useEffect } from "react";
import Request from "custom-hook-fetch-api";

const App = () => {
  const data = Request("https://api.coindesk.com/v1/bpi/currentprice.json", {method: "GET"});

  useEffect(() => {
    data.request();
  }, []);

  useEffect(() => {
    console.log(data.data);
  }, [data.data]);

  if (data.loading) return <div>Loading!!!</div>;
  if (data.error) return <div>Error!!!</div>;

  return <div className="App">Done</div>;
};

Readme

Keywords

none

Package Sidebar

Install

npm i custom-hook-fetch-api

Weekly Downloads

1

Version

1.2.0

License

ISC

Unpacked Size

2.05 kB

Total Files

4

Last publish

Collaborators

  • dimchukys