5Generated using Val.town
6
7Relies on the Zoomin Software bundle API to fetch the data using the JSON API, and then pluck and render the HTML part.
1export default async function (req: Request): Promise<Response> {
2 try {
3 const response = await fetch("https://help-be.zerto.com/api/bundle/Lifecycle.Matrix.HTML/page/product_version_lifecycle_matrix_for_zerto.html");
4
5 if (!response.ok) {
16 });
17 } catch (error) {
18 console.error('Error fetching data:', error);
19 return new Response(`<p>Error: ${error.message}</p>`, {
20 status: 500,
76 };
77
78 const response = await fetch(`${baseUrl}/users/me/goals/${goalSlug}/datapoints.json`, {
79 method: 'POST',
80 headers: {
113
114 // First, get the current goal to retrieve the roadall
115 const getResponse = await fetch(`${baseUrl}/users/me/goals/${goalSlug}.json?auth_token=${authToken}`);
116 if (!getResponse.ok) {
117 const error = await getResponse.json();
118 throw new Error(JSON.stringify({ error: 'Failed to fetch current goal', details: error }));
119 }
120
143 };
144
145 const response = await fetch(`${baseUrl}/users/me/goals/${goalSlug}.json`, {
146 method: 'PUT',
147 headers: {
206 }
207
208 const response = await fetch(`${baseUrl}/users/me/goals/${goalSlug}.json?auth_token=${token}`);
209 const goal: BeeminderGoal = await response.json();
210
211 if (!response.ok) {
212 return new Response(JSON.stringify({ error: 'Failed to fetch goal', details: goal }), {
213 status: response.status,
214 headers: { 'Content-Type': 'application/json' }
251 }
252
253 const response = await fetch(`${baseUrl}/users/me/goals/${goalSlug}/datapoints.json?auth_token=${token}`);
254 const datapoints = await response.json();
255
256 if (!response.ok) {
257 return new Response(JSON.stringify({ error: 'Failed to fetch datapoints', details: datapoints }), {
258 status: response.status,
259 headers: { 'Content-Type': 'application/json' }
47});
48
49export default app.fetch;
8await app.build();
9
10export default app.fetch;
4app.get("/", (c) => c.text("Hello world!"));
5app.get("/yeah", (c) => c.text("Routing!"));
6export default app.fetch;
7})
8
9export default app.fetch
20});
21
22// API endpoint to fetch user's vals
23app.get("/api/vals", async c => {
24 try {
32 }
33
34 // Fetch vals from Val Town API
35 const response = await fetch('https://api.val.town/v2/me/vals', {
36 headers: {
37 'Authorization': `Bearer ${apiToken}`,
70
71 } catch (error) {
72 console.error('Error fetching vals:', error);
73 return c.json<ApiResponse<null>>({
74 success: false,
91 }
92
93 const response = await fetch(`https://api.val.town/v1/vals/${valId}`, {
94 headers: {
95 'Authorization': `Bearer ${apiToken}`,
115
116 } catch (error) {
117 console.error('Error fetching val:', error);
118 return c.json<ApiResponse<null>>({
119 success: false,
123});
124
125export default app.fetch;
5 name: string;
6 code?: string; // Not always included in list responses
7 type?: 'http' | 'cron' | 'email' | 'script'; // Need to fetch from individual val
8 privacy: 'public' | 'private' | 'unlisted';
9 author: {
44
45 useEffect(() => {
46 fetchVals();
47 }, []);
48
49 const fetchVals = async () => {
50 try {
51 setLoading(true);
52 const response = await fetch('/api/vals');
53 const result = await response.json();
54
60 }
61 } catch (err) {
62 setError('Failed to fetch vals: ' + err.message);
63 } finally {
64 setLoading(false);
131 ) : null,
132 h('button', {
133 onClick: fetchVals,
134 className: 'bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 transition-colors'
135 }, 'Try Again')