MCPcopy Index your code
hub / github.com/smallfawn/QLScriptPublic / httpRequest

Function httpRequest

qtx.js:273–302  ·  view source on GitHub ↗
(options, method)

Source from the content-addressed store, hash-verified

271/////////////////////////////////////////////////////////////////////////////////////
272
273function 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 */

Callers 7

user_infoMethod · 0.70
task_signInMethod · 0.70
get_questionMethod · 0.70
do_questionMethod · 0.70
get_calMethod · 0.70
do_calMethod · 0.70
getNoticeFunction · 0.70

Calls 2

logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected