微信小程序 封装api 接口文件文件 与 调用

function accountsIdentity(params, method) {
  return new Promise((resolve) => {
    wx.request({
      url: `https://baidu.com/xxx/xxx`,
      data: params,
      method: method,
      success: (data) => {
        resolve(data.data)
      }
    })
  })
}
module.exports = {
  accountsIdentity
}
const axios = require('../../utils/axios.js') // 引用外部的js文件
const params = { type: 4, tenantId: 1164523599620829185 }
axios.accountsIdentity(params, 'get').then(res => {
    console.log(res)
})

 

你可能感兴趣的:(微信小程序)