( settings: ExtensionSettings, request: CaptureRequest, )
| 101 | } |
| 102 | |
| 103 | export async function postCapture( |
| 104 | settings: ExtensionSettings, |
| 105 | request: CaptureRequest, |
| 106 | ): Promise<CaptureResponse> { |
| 107 | const response = await fetch( |
| 108 | `http://localhost:${settings.apiPort}/captures/`, |
| 109 | { |
| 110 | body: JSON.stringify(request), |
| 111 | headers: { |
| 112 | 'Authorization': `Bearer ${settings.apiToken}`, |
| 113 | 'Content-Type': 'application/json', |
| 114 | }, |
| 115 | method: 'POST', |
| 116 | }, |
| 117 | ) |
| 118 | |
| 119 | if (!response.ok) { |
| 120 | throw new Error(await getErrorMessage(response)) |
| 121 | } |
| 122 | |
| 123 | return (await response.json()) as CaptureResponse |
| 124 | } |
| 125 | |
| 126 | export function isCaptureTarget(value: unknown): value is CaptureTarget { |
| 127 | return value === 'code' || value === 'notes' || value === 'http' |
no test coverage detected