use-ky
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

use-ky

Fetch-like hook using Ky.

Installation

yarn add use-ky

Usage

import { useKy } from 'use-ky'
 
function MyComponent() {
  const state = useKy(
    'https://example.com', { method: 'post', body: { json: { foo: true } } },
    (response) => response.json<ResponseFormat>()
  )
 
  console.log(state)
  // => { loading: true, data: null, error: null }
  // => { loading: true, data: '🦄', error: null }
}

/use-ky/

    Package Sidebar

    Install

    npm i use-ky

    Weekly Downloads

    5

    Version

    0.2.0

    License

    MIT

    Unpacked Size

    41.6 kB

    Total Files

    16

    Last publish

    Collaborators

    • sleeplessbyte