Basics
Getting StartedTypeScript
You can use TypeScript to get full type safety in your components. use-axios-client
ships type definitions, so there's no need to install any @types
packages.
# Example
- Define your data response shape:
interface Data {name: string;age: number;}
- Pass it to a hook:
const { data, error, loading } = useAxios<Data>({url: 'https://example/api',});
- Get type feedback as you develop:
return <div>{data.location}</div>;// Property 'location' does not exist on type '{ name: string; age: number; }'