ata
v0.3.3
Published
axios + auto encode url + ...
Downloads
14
Readme
- axios + auto encode url + ...
- fetch style requests with
$
prefixed methods, like axios-module - support string proxy config like
127.0.0.1:9000
Install
yarn add ata
# or
npm install ata
Usage
const Ata = require('ata')
const url = 'http://httpbin.org/get?show_env=1'
async function go() {
// const { data } = await Ata.get(url)
const data = await Ata.$get(url)
console.log(data)
}
go()
random useragent with random-mua
const Ata = require('ata')
const randomMua = require('random-mua')
Ata.interceptors.request.use(
function(config) {
if (!config.headers['User-Agent']) {
config.headers['User-Agent'] = randomMua()
}
return config
},
function(error) {
return Promise.reject(error)
}
)