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

Function httpRequest

hqcsh.js:310–331  ·  view source on GitHub ↗
(options, timeout = 1 * 1000)

Source from the content-addressed store, hash-verified

308
309//===============================================网络请求httpRequest=========================================
310function httpRequest(options, timeout = 1 * 1000) {
311 method = options.method ? options.method.toLowerCase() : options.body ? "post" : "get";
312 return new Promise(resolve => {
313 setTimeout(() => {
314 $[method](options, (err, resp, data) => {
315 try {
316 if (err) {
317 console.log(JSON.stringify(err));
318 $.logErr(err);
319 } else {
320 try { data = JSON.parse(data); } catch (error) { }
321 }
322 } catch (e) {
323 console.log(e);
324 $.logErr(e, resp);
325 } finally {
326 resolve(data);
327 }
328 })
329 }, timeout)
330 })
331}
332//==============================================Debug模式===============================================
333function debugLog(...args) {
334 if (debug) {

Callers 1

getNoticeFunction · 0.70

Calls 2

logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected