Build a minimal Response-like object for fetch mocks.
( body: unknown, status = 200, contentType = 'application/json', )
| 18 | |
| 19 | /** Build a minimal Response-like object for fetch mocks. */ |
| 20 | function makeResponse( |
| 21 | body: unknown, |
| 22 | status = 200, |
| 23 | contentType = 'application/json', |
| 24 | ): Response { |
| 25 | const bodyText = |
| 26 | typeof body === 'string' ? body : JSON.stringify(body); |
| 27 | return new Response(bodyText, { |
| 28 | status, |
| 29 | headers: { 'Content-Type': contentType }, |
| 30 | }); |
| 31 | } |
| 32 | |
| 33 | // ── resolveApiBase ──────────────────────────────────────────────────────────── |
| 34 |