0.3.0 • Published 12 months ago

f14-fetch-interceptor v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

F14 Fetch Interceptor

A simple tool for fetch data and intercept errors

Quick start

npm i f14-fetch-interceptor

Fetch data

const f14 = new F14()

f14.get('full api url')
f14.post('full api url', false, {
  key: 'body data'
})

Now you can use GET, POST, PATCH, PUT, DELETE methods

Main Settings

You can set main instance of F14

import F14 from 'f14-fetch-interceptor'

export const f14Instance = new F14()
  .settings({
    apiUrl: 'url path'
    headers: {
      'Content-Type': 'application/json'
    }
  }).auth(() => {
    const jwtToken = ... get token

    return jwtToken
  }).intercept401(() => {
    ... refresh Token

    return true
  })

If you want use store inside F14 -> inject it

const someStore

f14Instance.injectStore(someStore)

Then you will be able to use dispatch and getState

.auth((dispatch, getState) => {
    const jwtToken = ... get token

    return jwtToken
  })
0.3.0

12 months ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.4

12 months ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago