({ method = "GET", apiPath, shopId = "", token = "", params = {}, data = {}, bizCode = "" })
| 313 | } |
| 314 | |
| 315 | async request({ method = "GET", apiPath, shopId = "", token = "", params = {}, data = {}, bizCode = "" }) { |
| 316 | const options = { |
| 317 | method, |
| 318 | url: `${this.app.apiBase}${apiPath}`, |
| 319 | headers: this.headers(shopId, token, bizCode ? { "JJ-BizCode": bizCode } : {}), |
| 320 | timeout: 20000, |
| 321 | validateStatus: () => true, |
| 322 | }; |
| 323 | if (method === "GET") options.params = params; |
| 324 | else options.data = data; |
| 325 | |
| 326 | const { data: result, status } = await axios.request(options); |
| 327 | if (status > 400) throw new Error(`HTTP ${status}: ${JSON.stringify(result)}`); |
| 328 | return result; |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | class ShopTask { |
no test coverage detected