tmaito-fetch
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

tmaito-fetch

基于restfull规范通用的 http 请求库

该库基于axios封装,axios的参数全部都能支持。详见axios官网

Usage

const { fetch, Cookie, CryptoJS, defaultConfig } = require('tmaito-fetch');

defaultConfig // 可设置默认参数 同 axios.defaults

fetch({
  url: 'xxx/xxx',
  data: {
    arg1: 1
	},
	headers: {
    'x-access-token': 'test'
  },
  method: 'post', // 默认为POST
  cancelRedirect: false, // 是否需要重定向 默认 false
  cancelToken: false, // 是否启动 相同接口多次请求,在前一次接口未结束时,后续接口做取消请求操作
	response: false, // 返回结果是否为 response,默认 true 返回 data
}).then(res => {
  console.log(res)
}).catch(e => {
  console.error(e)
})

Cookie.set(key, value), // 设置
Cookie.get(key), // 获取
Cookie.remove(key) // 移除
// 注意: cookie 针对的 domain 为一级域名


const {
  Decrypt, // 解密方法
	Encrypt, // 加密方法
} = CryptoJS;

Readme

Keywords

Package Sidebar

Install

npm i tmaito-fetch

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

285 kB

Total Files

12

Last publish

Collaborators

  • zmh7057