* * @param {string} title * @param {{ accountId: string; accountEmail: string | undefined; apiKey: string; }} args
(title, args)
| 280 | * @param {{ accountId: string; accountEmail: string | undefined; apiKey: string; }} args |
| 281 | */ |
| 282 | async function getNamespace(title, args) { |
| 283 | const response = await fetch( |
| 284 | `${apiBase}/accounts/${args.accountId}/storage/kv/namespaces?per_page=100`, |
| 285 | { |
| 286 | headers: buildAuthHeaders(args.apiKey, args.accountEmail) |
| 287 | } |
| 288 | ); |
| 289 | if (!response.ok) { |
| 290 | throw new Error( |
| 291 | `Error fetching namespaces - ${response.status}: ${ |
| 292 | response.statusText |
| 293 | }\n${await response.text()}` |
| 294 | ); |
| 295 | } |
| 296 | const data = await response.json(); |
| 297 | // @ts-ignore |
| 298 | return data.result.find(x => x.title === title); |
| 299 | } |
| 300 | |
| 301 | /** |
| 302 | * |
no test coverage detected