MCPcopy
hub / github.com/CapSoftware/Cap / fetchLoomEndpoint

Function fetchLoomEndpoint

apps/web/actions/loom.ts:138–177  ·  view source on GitHub ↗
(
	videoId: string,
	endpoint: string,
	includeBody = true,
)

Source from the content-addressed store, hash-verified

136}
137
138async 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
179async function fetchVideoName(videoId: string): Promise<string | null> {
180 try {

Callers 1

getLoomDownloadUrlFunction · 0.70

Calls 1

fetchFunction · 0.50

Tested by

no test coverage detected