1export async function createProject(projectName: string) {
2 const response = await fetch('/api/projects', {
3 method: 'POST',
4 headers: {
95 if (failedFiles.length > 0) {
96 const failedFilesList = failedFiles.map(f => `'${f.path}': ${f.error}`).join(", ");
97 throw new Error(`Failed to fetch content for files: ${failedFilesList}`);
98 }
99
107});
108
109// HTTP vals expect an exported "fetch handler"
110// This is how you "run the server" in Val Town with Hono
111export default app.fetch;
11 const onExportClick = async () => {
12 if (name && username) {
13 const response = await fetch(`/text?name=${name}&username=${username}`);
14 const data = await response.text();
15 setText(data);
15 const start = performance.now();
16 try {
17 res = await fetch(url);
18 end = performance.now();
19 status = res.status;
25 } catch (e) {
26 end = performance.now();
27 reason = `couldn't fetch: ${e}`;
28 ok = false;
29 }
11
12 try {
13 const response = await fetch("/messages", {
14 method: "POST",
15 headers: { "Content-Type": "application/json" },
60});
61
62// HTTP vals expect an exported "fetch handler"
63// This is how you "run the server" in Val Town with Hono
64export default app.fetch;
9 const [messages, setMessages] = React.useState(initialMessages);
10
11 const fetchMessages = async () => {
12 try {
13 const response = await fetch("/messages");
14 const data = await response.json();
15 setMessages(data.reverse());
16 } catch (error) {
17 console.error("Failed to fetch messages", error);
18 }
19 };
23 <h1>💬 Message Board!</h1>
24 <MessageList messages={messages} />
25 <MessageInput onSubmit={fetchMessages} />
26 {thisProjectURL
27 ? (
13The following vals could not be imported:
14
15- [g/countGithubLOC](https://www.val.town/v/g/countGithubLOC) - Failed to fetch val: {"statusCode":404,"error":"Not Found","message":"Could not find that val"}
16
17
1/**
2 * This val creates a website to count lines of code in GitHub repositories.
3 * It uses a server-side API to fetch the data and a client-side UI for user interaction.
4 * It now includes sharing functionality and URL manipulation for better user experience.
5 */
185
186 try {
187 const response = await fetch(`/api/${user}/${repo}`);
188 const data = await response.json();
189
315});
316
317export default app.fetch;
15 const start = performance.now();
16 try {
17 res = await fetch(url);
18 end = performance.now();
19 status = res.status;
25 } catch (e) {
26 end = performance.now();
27 reason = `couldn't fetch: ${e}`;
28 ok = false;
29 }