@fishdeveloper/usefetch
v1.1.0
Published
### Features
Downloads
65
Readme
useFetch
Features
- Make XMLHttpRequests from the browser
- Automatic transforms for JSON data
Installing
Package manager
Using npm:
$ npm install @fishdeveloper/usefetch
Using yarn:
$ yarn add @fishdeveloper/usefetch
Using pnpm:
$ pnpm add @fishdeveloper/usefetch
Once the package is installed, you can import the library using import
approach:
import { useFetch } from "@fishdeveloper/usefetch";
Example
import { useFetch } from "@fishdeveloper/usefetch";
useFetch("todos/1", {
baseURL: "https://jsonplaceholder.typicode.com",
headers: { "X-Custom-Header": "foobar" },
}).then((res) => console.log(res));
// output = {
// data: {
// "userId": 1,
// "id": 1,
// "title": "delectus aut autem",
// "completed": false
// }
// }