http

TIP

http服务调用

downloadFile(url, localDirectoryCode, filename)

下载文件

参数类型作用备注
urlstring请求路径
localDirectoryCodestring本地文件目录端点编码
filenamestring文件名

例 :

const respose = await api.http.downloadFile('/test2','123abc','1.xlsx')

directGet(url, header)

HTTP接口GET请求

参数类型作用备注
urlstring请求路径
headerobject请求头

例 :

const respose = await api.http.directGet(
  '/test'
)

directPost(url, data, header)

HTTP接口POST请求

参数类型作用备注
urlstring请求路径
dataobject请求数据
headerobject请求头

例 :

const data = [
  { code: 'zhangsan', name: '张三' },
  { code: 'lisi', name: '李四' }
]
const respose = await api.http.directPost(
  '/test',
  data
)

get(serverCode, path, data, header)

调用HTTP服务的GET

参数类型作用备注
serverCodestring数据端点: 远程http接口
pathstring请求路径
dataobject请求数据
headerobject请求头

例 :

const data = [
  { code: 'zhangsan', name: '张三' },
  { code: 'lisi', name: '李四' }
]
const respose = await api.http.get(
  '123abc',
  '/test',
  data
)

httpCall(serverCode, path, method, data[, header])

调用HTTP服务

  • 返回 无
参数类型作用备注
serverCodestring数据端点: 远程http接口
pathstring请求路径
methodstring请求方式GET、POST
dataobject请求数据
headerobject请求头可选

例 :

const data = [
  { code: 'zhangsan', name: '张三' },
  { code: 'lisi', name: '李四' }
]
const respose = await api.http.httpCall(
  '123abc',
  '/test',
  'GET'
)
const data = [
  { code: 'zhangsan', name: '张三' },
  { code: 'lisi', name: '李四' }
]
const token = 'token123'
const respose = await api.http.httpCall(
  '123abc',
  '/test2',
  'POST',
  data,
  {
      token:token
  }
)


post(serverCode, path, data, header)

调用HTTP服务的POST

参数类型作用备注
serverCodestring服务器数据端点编码
pathstring请求路径
dataarray请求数据
headerobject请求头

例 :

const data = [
  { code: 'zhangsan', name: '张三' },
  { code: 'lisi', name: '李四' }
]
const token = 'token123'
const respose = await api.http.post(
  '123abc',
  '/test2',
  data,
  {
      token:token
  }
)

setHttpResponse(text)

返回数据

参数类型作用备注
text返回内容

例 :

    api.http.setHttpResponse({
        code: 1,
        message: "信息"
    })