Browse Source

请求库 添加 Method 常量

master
lqq 6 years ago
parent
commit
f315154761
  1. 12
      utils/http.js

12
utils/http.js

@ -1,14 +1,20 @@
import { config } from '../config.js'
const Method = {
GET: 'GET',
POST: 'POST'
}
class HTTP {
constructor() {
this.baseUrl = config.api_url
}
request = (params) => {
let url = this.baseUrl + params.url
if (!params.method) {
params.method = 'GET'
params.method = Method.GET
}
console.log(params)
wx.request({
url: url,
data: params.data,
@ -35,4 +41,4 @@ class HTTP {
})
}
}
export { HTTP }
export { HTTP, Method }

Loading…
Cancel
Save