( videoId: string, endpoint: string, includeBody = true, )
| 136 | } |
| 137 | |
| 138 | async function fetchLoomEndpoint( |
| 139 | videoId: string, |
| 140 | endpoint: string, |
| 141 | includeBody = true, |
| 142 | ): Promise<string | null> { |
| 143 | try { |
| 144 | const options: RequestInit = { method: "POST" }; |
| 145 | if (includeBody) { |
| 146 | options.headers = { |
| 147 | "Content-Type": "application/json", |
| 148 | Accept: "application/json", |
| 149 | }; |
| 150 | options.body = JSON.stringify({ |
| 151 | anonID: randomUUID(), |
| 152 | deviceID: null, |
| 153 | force_original: false, |
| 154 | password: null, |
| 155 | }); |
| 156 | } |
| 157 | |
| 158 | const response = await fetch( |
| 159 | `https://www.loom.com/api/campaigns/sessions/${videoId}/${endpoint}`, |
| 160 | options, |
| 161 | ); |
| 162 | |
| 163 | if (!response.ok || response.status === 204) { |
| 164 | return null; |
| 165 | } |
| 166 | |
| 167 | const text = await response.text(); |
| 168 | if (!text.trim()) { |
| 169 | return null; |
| 170 | } |
| 171 | |
| 172 | const data: LoomUrlResponse = JSON.parse(text); |
| 173 | return data.url ?? null; |
| 174 | } catch { |
| 175 | return null; |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | async function fetchVideoName(videoId: string): Promise<string | null> { |
| 180 | try { |
no test coverage detected