0.0.7 • Published 1 year ago

@xunjing/utils v0.0.7

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

@xunjing/utils

快速开始

npm install @xunjing/utils

使用

// 项目新增 request.js
import { createApi, getHost } from '@xunjing/utils'

const onError = (err) => {
  // 这里放错误处理函数,以uni-app为例
  uni.showToast({
    title: err?.msg || '服务器异常',
    icon: 'error',
  })
}

// getHost('{服务名}'), 默认BASE,现在只有这一个
const api = createApi({ baseURL: getHost(), onError })

export default api
// 使用和axios一样
api.get('/getxxById', { params: { id } })
api.post('/createProject', params)

http状态码

401登录过期,自动跳转到/login

返回格式

msg: 服务端返回信息
data: 返回数据
success: 业务请求是否成功,!= true时报错

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago