1.0.0-beta • Published 6 years ago

chainr-proxy-axios v1.0.0-beta

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

chainr-axios

Combination of axios and chainr to make http requests.

import { createAxios } from 'chainr-proxy-axios'

const instance = createAxios({
  baseURL: 'http://example.com/api',
  rules: [
    { match: /^(insert|update)/, method: 'post' }
  ]
})

// GET http://example.com/api/getUsers
instance.getUsers()

// POST http://example.com/api/updateUser
// with data { id: 0, name: 'hjkcai' }
instance.updateUser({ id: 0, name: 'hjkcai' })

// POST http://example.com/api/insertUser
// Authorization: xxx
instance.insertUser({ name: 'shirley' }, {
  headers: { Authorization: 'xxx' }
})

API

coming soon...