0.2.5 • Published 4 years ago

react-requests-fetch v0.2.5

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

React Request Fetch Hook

The given dependency, react-requests-fetch is a ReactJS target library for handling http fetch requests considering bia-directional stateless and stateful data extraction. The same logic and parameters used when performing http requests using the fetch api are kept, with the difference in flexibility as to how data is retrieved. Data can be retrieved from any given source (api: precisely), either by initializing this hook when the component renders or is to render with statics variables, or dynamic variables within the source code, the same way as the react's use state hook is expected to be called.

import useRequestFetch from "react-requests-fetch";

const [response, setRequest] = useRequestFetch({
   uri: "https://restcountries.eu/rest/v2/all"
});

<button onClick={() => {
    setRequest({
        uri: "https://restcountries.eu/rest/v2/alpha/col"
    })
}}>Fetch Data</button>

<p>{response.loading && "Fetching..."}</p>
<pre>{JSON.stringify(response, null, 2)}</pre>
{
    "statusCode": 200,
    "loading": false,
    "payload": []
}
0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.0

4 years ago

0.1.1

4 years ago

0.1.4

4 years ago

0.1.5

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago