(options, method)
| 271 | ///////////////////////////////////////////////////////////////////////////////////// |
| 272 | |
| 273 | function httpRequest(options, method) { |
| 274 | typeof (method) === 'undefined' ? ('body' in options ? method = 'post' : method = 'get') : method = method |
| 275 | return new Promise((resolve) => { |
| 276 | $[method](options, (err, resp, data) => { |
| 277 | try { |
| 278 | if (err) { |
| 279 | console.log(`${method}请求失败`); |
| 280 | $.logErr(err); |
| 281 | //throw new Error(err); |
| 282 | //console.log(err); |
| 283 | } else { |
| 284 | //httpResult = data; |
| 285 | //httpResponse = resp; |
| 286 | if (data) { |
| 287 | //console.log(data); |
| 288 | typeof JSON.parse(data) == 'object' ? data = JSON.parse(data) : data = data |
| 289 | resolve(data) |
| 290 | } else { |
| 291 | console.log(`请求api返回数据为空,请检查自身原因`) |
| 292 | } |
| 293 | } |
| 294 | } catch (e) { |
| 295 | //console.log(e, resp); |
| 296 | $.logErr(e, resp); |
| 297 | } finally { |
| 298 | resolve(); |
| 299 | } |
| 300 | }) |
| 301 | }) |
| 302 | } |
| 303 | /** |
| 304 | * 获取远程版本 |
| 305 | */ |
no test coverage detected