Getting started
Installation
Prerequisites
- Node.js version 18 or higher.
- A package manager: e.g. npm, pnpm, ...
sh
$ npm add @ogs-gmbh/use-axiossh
$ pnpm add @ogs-gmbh/use-axiossh
$ yarn add @ogs-gmbh/use-axiossh
$ bun add @ogs-gmbh/use-axiosUsage
Here we provide a simple example. Get a deeper understanding in our reference.
example.ts
tsx
import { useAxios } from "@ogs-gmbh/use-axios";
function MyComponent () {
const { hasError, data } = useAxios({
method: "get",
url: "https://jsonplaceholder.typicode.com/todos/1"
})
return (
<>
{
hasError
? "Request failed. Try again."
: <p>{data.title}</p>
}
</>
)
}