0.0.6 • Published 11 months ago

@w-s/http v0.0.6

Weekly downloads
-
License
-
Repository
-
Last release
11 months ago

OS子系统请求库

  • 公参注入
  • 可根据不同业务线更改baseUrl
  • 可以根据不同业务线注入请求拦截器响应拦截器
  • 基于json方式请求和响应

业务使用

npm i @ws/http -S

更改baseURL

不更改 baseURL 或者 createFetch 不传入参数, 则baseURL就是 window.location.origin

src/utils/http.js

导出实例

import { createFetch } from '@ws/http'

export const http = createFetch({
  baseURL: 'http://test.com/api'
})

定义api

import { http } from '@/utils/http.js'

export const getHomePaegList = async (data) => {
  return await http.post('/remoteApi/user/service/os/pageModel/selectPageList', data)
}

vue文件中使用

<script>
import {getHomePaegList} from '@/apis/homeConfig.js'

export default {
  mounted() {
    this.getList()
  },
  methods: {
    async getList() {
      try {
        let res = await getHomePaegList({
           currentPage: 1,
           pageSize: 10,
           op: 'create'
        })

        console.log(res);
      } catch (error) {}
    }
  }
}
</script>

更新版本

# 更新版本号, 打tag
npm version patch

# 推送代码 + tag到 gitlab
npm run postversion

# 发布npm 包
npm publish
0.0.6

11 months ago