react-custom-fetch

1.0.0 • Public • Published

react-custom-fetch

a custom React hook to Fetch Data

Install

npm install --save react-custom-fetch

Usage

To use the UseFetch hook, you can import it into your React component and call it with a string argument that has your api endpoint for which you want to get the response of data. The hook will default have a dummy json fetched data for testing if you don't pass anything. You can use isLoading to handle loading and errorStatus to check the api request.

import { UseFetch } from "react-custom-fetch";

const App = () => {
  const { data, isLoading, errorStatus } = UseFetch("");
  if (isLoading) {
    return <>loading..........</>;
  }
  return (
    <div className="App">
      {data?.products?.map((s) => (
          <img src={s?.images?.[0]} alt="" />
      ))}
      test
    </div>
  );
};

export default App;

Readme

Keywords

none

Package Sidebar

Install

npm i react-custom-fetch

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

2.08 kB

Total Files

3

Last publish

Collaborators

  • techy_jay