hjkcai / chainr-axios

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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...

About

License:MIT License


Languages

Language:JavaScript 82.7%Language:TypeScript 17.3%