134});
135
136export default app.fetch;
14 start = performance.now();
15 try {
16 const res = await fetch(url);
17 end = performance.now();
18 status = res.status;
25 } catch (e) {
26 end = performance.now();
27 reason = `couldn't fetch: ${e}`;
28 ok = false;
29 console.log(`Website down (${url}): ${reason} (${end - start}ms)`);
58 });
59
60 const res = await fetch("https://api.pinata.cloud/pinning/pinJSONToIPFS", {
61 method: "POST",
62 headers: {
24 }
25 }
26 const resp = await fetch(`https://api.val.town/v1/alias/${author}/${name}`, {
27 headers,
28 });
173app.get('/main.js', serve(js, 'text/javascript'));
174
175export default app.fetch;
51app.get('/main.js', serve(js, 'text/javascript'));
52
53export default app.fetch;
81 setError("");
82 try {
83 const response = await fetch("/generate", {
84 method: "POST",
85 headers: { "Content-Type": "application/json" },
35
36async function execute(statement: InStatement, args?: InArgs): Promise<ResultSet> {
37 const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38 method: "POST",
39 headers: {
50
51async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
52 const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
53 method: "POST",
54 headers: {
8
9 useEffect(() => {
10 fetchSavedDrawings();
11 }, []);
12
13 const fetchSavedDrawings = async () => {
14 const response = await fetch('/list-drawings');
15 const drawings = await response.json();
16 setSavedDrawings(drawings);
18
19 const handleSave = async () => {
20 const response = await fetch('/save-drawing', {
21 method: 'POST',
22 headers: { 'Content-Type': 'application/json' },
24 });
25 if (response.ok) {
26 fetchSavedDrawings();
27 }
28 };
1/**
2 * This API integrates with Calendly to fetch personal events for the current week.
3 * It returns the events as raw JSON.
4 *
18 try {
19 // First, get the user's URI
20 const userResponse = await fetch('https://api.calendly.com/users/me', {
21 headers: {
22 'Content-Type': 'application/json',
26
27 if (!userResponse.ok) {
28 throw new Error(`Failed to fetch user data: ${userResponse.status} ${userResponse.statusText}`);
29 }
30
37 const endOfWeek = new Date(today.setDate(today.getDate() - today.getDay() + 6));
38
39 // Now fetch the events using the user's URI
40 const eventsUrl = `https://api.calendly.com/scheduled_events?user=${userUri}&min_start_time=${startOfWeek.toISOString()}&max_start_time=${endOfWeek.toISOString()}`;
41
42 const eventsResponse = await fetch(eventsUrl, {
43 headers: {
44 'Content-Type': 'application/json',
48
49 if (!eventsResponse.ok) {
50 throw new Error(`Failed to fetch Calendly events: ${eventsResponse.status} ${eventsResponse.statusText}`);
51 }
52