api-grabber
v0.2.5
Published
for fetching (grabbing) data from an Api in react app
Downloads
8
Readme
Getting Started with Api-Grabber
for fetching (grabbing) data from an Api in react app
Installation
npm i api-grabber
Usage
import { GrabberRequest } from "api-grabber";
import { IRequest } from "api-grabber/dist/components";
import { useState } from "react";
import { Button } from "react-bootstrap";
export const MyComponent = () => {
const onGetData = () => {};
const onError = () => {};
const onLoading = () => {};
const [request, setRequest] = useState<IRequest>({
onGetData,
onError,
isRequest: true,
onLoading,
path: "http://localhost:3000/user",
method :'GET'
});
const getPosts = ()=>{
setRequest({
...request,
isRequest: true,
path: "http://localhost:3000/posts",
})
}
return (
<div>
<Button onClick={getPosts}></Button>
<GrabberRequest {...request} />
</div>
);
};
end