(path, body, method = "POST")
| 36 | .slice(0, 80); |
| 37 | |
| 38 | async function algoliaRequest(path, body, method = "POST") { |
| 39 | const response = await fetch(`${algoliaHost}${path}`, { |
| 40 | method, |
| 41 | headers: algoliaHeaders, |
| 42 | body: JSON.stringify(body), |
| 43 | }); |
| 44 | |
| 45 | if (!response.ok) { |
| 46 | const text = await response.text(); |
| 47 | throw new Error(`Algolia request failed ${response.status}: ${text}`); |
| 48 | } |
| 49 | |
| 50 | return response.json(); |
| 51 | } |
| 52 | |
| 53 | async function fetchText(url) { |
| 54 | const response = await fetch(url, { |