-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmit.ts
More file actions
29 lines (24 loc) · 773 Bytes
/
Copy pathsubmit.ts
File metadata and controls
29 lines (24 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
interface GogglesSubmitResponse {
success: boolean;
goggle?: {
goggleID: string;
name: string;
transferred_from?: string;
[key: string]: any;
};
errors?: [number, string][];
message?: string;
}
async function submitGoggle(goggleUrl: string): Promise<GogglesSubmitResponse> {
const endpoint = new URL('https://search.brave.com/api/goggles/submit');
endpoint.searchParams.set('url', goggleUrl);
const res = await fetch(endpoint, { method: 'POST' });
if (!res.ok) {
throw new Error(`Failed to submit Goggle: ${res.status} ${res.statusText}`);
}
return await res.json();
}
const result = await submitGoggle(
'https://raw.githubusercontent.com/T1ckbase/smallweb-goggle/refs/heads/master/smallweb.goggle',
);
console.log(result);