1.1.5 • Published 4 years ago

@hazelee/refetch v1.1.5

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

Refetch

Refetch is Simple HTTP Client by Fetch API. And Heavily inspired from r2.

Usage

npm install --save @hazelee/refetch
import refetch from '@hazelee/refetch'

// in async function...
const result = await refetch('https://api.github.com/repos/hazealign/refetch', { method: 'get' }).json()
const result2 = await refetch.get('https://api.github.com/repos/hazealign/refetch').json()

// Put URL Search Parameter (Query) in Options.
// It doesn't supports in fetch API's standard.
const myIp = await refetch('https://api.ipify.org', {
  query: { format: 'json' },
  // query: '?format=json',
  // query: new URLSearchParams(),
}).json()

Changelogs

v1.1.0 (2020-07-10)

  • Update Latest Dependencies.
  • Save Response Data in PartialResponse when evaluating same refetch function.

     const base = refetch('https://api.github.com/repos/hazealign/refetch', { method: 'get' })
    
     const text = await base.text()
     // already Response result is cached in PartialResponse. ;)
     const json = await base.json()
  • Support query parameter in options. No more create URL instance and URLSearchParams instance. ;)

Why?

R2 is awesome project. But it isn't friendly with TypeScript. Refetch is written with TypeScript, and It also works well with plain JavaScript too.

Links

1.1.5

4 years ago

1.1.4

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.0.0

5 years ago