(function_id, body = {})
| 608 | } |
| 609 | // 请求 |
| 610 | async function request(function_id, body = {}) { |
| 611 | await $.wait(3000); //歇口气儿, 不然会报操作频繁 |
| 612 | return new Promise((resolve, reject) => { |
| 613 | $.post(taskUrl(function_id, body), (err, resp, data) => { |
| 614 | try { |
| 615 | if (err) { |
| 616 | console.log('\n东东萌宠: API查询请求失败 ‼️‼️'); |
| 617 | console.log(JSON.stringify(err)); |
| 618 | $.logErr(err); |
| 619 | } else { |
| 620 | data = JSON.parse(data); |
| 621 | } |
| 622 | } catch (e) { |
| 623 | $.logErr(e, resp); |
| 624 | } finally { |
| 625 | resolve(data) |
| 626 | } |
| 627 | }) |
| 628 | }) |
| 629 | } |
| 630 | // function taskUrl(function_id, body = {}) { |
| 631 | // return { |
| 632 | // url: `${JD_API_HOST}?functionId=${function_id}&appid=wh5&loginWQBiz=pet-town&body=${escape(JSON.stringify(body))}`, |
no test coverage detected