(host, apiPath, data = {}, allowFail = false)
| 132 | } |
| 133 | |
| 134 | async api(host, apiPath, data = {}, allowFail = false) { |
| 135 | const res = await request({ |
| 136 | method: "POST", |
| 137 | url: `${host}${apiPath}`, |
| 138 | headers: this.headers(), |
| 139 | data, |
| 140 | }); |
| 141 | if (res.status !== 200 && !allowFail) throw new Error(`HTTP ${res.status}: ${short(res.data)}`); |
| 142 | return res.data; |
| 143 | } |
| 144 | |
| 145 | async login() { |
| 146 | if (this.token) { |
no test coverage detected