(method, path, body)
| 167 | } |
| 168 | |
| 169 | async function request(method, path, body) { |
| 170 | const response = await fetch(`${serverUrl}${path}`, { |
| 171 | method, |
| 172 | headers: body ? { "content-type": "application/json" } : undefined, |
| 173 | body: body ? JSON.stringify(body) : undefined, |
| 174 | }); |
| 175 | const text = await response.text(); |
| 176 | if (!response.ok) { |
| 177 | throw new Error( |
| 178 | `${method} ${path} failed with ${response.status}: ${text.slice(0, 500)}`, |
| 179 | ); |
| 180 | } |
| 181 | if (!text) { |
| 182 | return null; |
| 183 | } |
| 184 | try { |
| 185 | return JSON.parse(text); |
| 186 | } catch { |
| 187 | return text; |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | function sampleRss(label) { |
| 192 | if (!pid) { |
no test coverage detected