Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/?q=fetch&page=1&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=fetch

Returns an array of strings in format "username" or "username/projectName"

Found 13737 results for "fetch"(1950ms)

Proxied fetch210 words

https://docs.val.town/std/fetch/
Proxied fetch. Copy page Copy page. Copy this page as Markdown for LLMs. View as Markdown View this page as plain text. Open in ChatGPT Ask questions about this page.

Sections

Proxied fetch

Proxied fetch. Copy page Copy page. Copy this page as Markdown for LLMs. View as Markdown View this page as plain text. Open in ChatGPT Ask questions about this page.

Usage

“Usage” After importing std/fetch, the fetch method is used with the same signature as the Javascript Fetch API. ExampleRun in Val Town ↗ import { fetch } from "https://esm.town/v/std/fetch"; let

Send messages to Slack284 words

https://docs.val.town/integrations/slack/send-messages-to-slack/
environment variable as slackWebhookURL. Use fetch to send a message. Section titled “Use fetch to send a message” Translate the sample cURL request to a fetch request. You can run

Sections

Use fetch to send a message

Use fetch to send a message. Section titled “Use fetch to send a message” Translate the sample cURL request to a fetch request. You can run the following val: Send

Early Return478 words

https://docs.val.town/vals/http/early-return/
Promise, not a useful value. const result = fetch("https://google.com/"); } catch (e) { // Errors will never be caught here because. // fetch is not awaited. handleError(e); } } HTTP

Sections

How to set up a queue

{ // Send off the relevant data a queue HTTP file. // This `fetch` is not awaited. fetch("https://my-queue.web.val.run", { method: "POST", body: req.body, }); // Respond immediately, before the queued

Promises should otherwise be awaited

Promise, not a useful value. const result = fetch("https://google.com/"); } catch (e) { // Errors will never be caught here because. // fetch is not awaited. handleError(e); } }

Google Sheets1356 words

https://docs.val.town/integrations/google-sheets/
string of characters between /d/ and /edit. 6. Fetch a Google Sheets access token and use it in your val. Section titled “6. Fetch a Google Sheets access token and

Sections

Google Sheets

have two options for authenticating with the Google Sheets API: Use Pipedream’s Accounts API to fetch a fresh OAuth access token at runtime. Use your own Google Cloud service account.

Use Pipedream’s Accounts API

you connect your Google Sheets account to Pipedream, you can use the Accounts API to fetch a fresh token within your val and use that token to authenticate requests to

1. Sign up for Pipedream and retrieve your API key

your key: You’ll use this key to authenticate requests to the Accounts API, letting you fetch Google Sheets access tokens in your val.

6. Fetch a Google Sheets access token and use it in your val

6. Fetch a Google Sheets access token and use it in your val. Section titled “6. Fetch a Google Sheets access token and use it in your val” In your

Send Discord message via webhook129 words

https://docs.val.town/integrations/discord/send-message/
send the message. Discord webhookRun in Val Town ↗ import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=5"; // pin to proxied fetch. export const discordWebhook = async ({ url, content, }: {

Sections

Send Discord message via webhook

send the message. Discord webhookRun in Val Town ↗ import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=5"; // pin to proxied fetch. export const discordWebhook = async ({ url, content, }: {

Github user's stars (pagination)436 words

https://docs.val.town/integrations/github/github-users-stars-pagination/
@vtdocs/getGithubStarsRun in Val Town ↗ import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41"; export const getGithubStars = async (username: string) => { const user = await fetchJSON( `https://api.github.com/users/${username}`, ); let totalStars =

Sections

Github user's stars (pagination)

@vtdocs/getGithubStarsRun in Val Town ↗ import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41"; export const getGithubStars = async (username: string) => { const user = await fetchJSON( `https://api.github.com/users/${username}`, ); let totalStars =

Email yourself when you get a comment reaction!

} from "https://esm.town/v/vtdocs/githubPatToken"; import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41"; export const emailGithubReactions = async () => { const username = "stevekrouse"; const events = await fetchJSON( `https://api.github.com/users/${username}/events?per_page=100`, { headers: {

Web scraping439 words

https://docs.val.town/guides/web-scraping/
ChatGPT Ask questions about this page. You can use vals to scrape websites, either by fetching HTML and using a parsing library, or by making an API call to an

Sections

Web scraping

ChatGPT Ask questions about this page. You can use vals to scrape websites, either by fetching HTML and using a parsing library, or by making an API call to an

Locate the HTML element that contains the data you need

Right click on the section of a website that contains the data you want to fetch and then inspect the element. In Chrome, the option is called Inspect and it

Parsing HTML

linkedom. ExampleRun in Val Town ↗ import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=6"; import { load } from "npm:cheerio"; const html = await fetchText( "https://en.wikipedia.org/wiki/OpenAI", ); const $ = load(html); //

Get a Github user196 words

https://docs.val.town/integrations/github/get-a-github-user/
@vtdocs/getGithubUserRun in Val Town ↗ import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41"; export const getGithubUser = async (username: string) => { const user = await fetchJSON( `https://api.github.com/users/${username}`, ); return user; };

Sections

Get a Github user

@vtdocs/getGithubUserRun in Val Town ↗ import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41"; export const getGithubUser = async (username: string) => { const user = await fetchJSON( `https://api.github.com/users/${username}`, ); return user; };

Express410 words

https://docs.val.town/legacy-vals/express/
res.json({ data: `Hello + ${req.body.name}!` }); }; Fetch @user/postWebhookRun in Val Town ↗ import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON"; export let postWebhookTest1 = fetchJSON( "https://user-postWebhook.express.val.run", { method: "POST", body: JSON.stringify({

Sections

handle-val.express.val.run

res.json({ data: `Hello + ${req.body.name}!` }); }; Fetch @user/postWebhookRun in Val Town ↗ import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON"; export let postWebhookTest1 = fetchJSON( "https://user-postWebhook.express.val.run", { method: "POST", body: JSON.stringify({

Browserless434 words

https://docs.val.town/integrations/browserless/
is to use a headless browser that runs a web browser in the background that fetches the page, renders it, and then allows you to search the final document. Services

Sections

Browserless

is to use a headless browser that runs a web browser in the background that fetches the page, renders it, and then allows you to search the final document. Services

Make an API call to the /scrape API

wikipedia page. Scrape API exampleRun in Val Town ↗ import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41"; const res = await fetchJSON( `https://chrome.browserless.io/scrape?token=${Deno.env.get("browserless")}`, { method: "POST", body: JSON.stringify({ url: "https://en.wikipedia.org/wiki/OpenAI", elements: [

workflowmain.tsx2 matches

@svc•Updated 16 mins ago
340
341 try {
342 const res = await fetch(window.location.pathname + '?action=startWorkflow', {
343 method: 'POST',
344 headers: {'Content-Type': 'application/json'},
386
387 try {
388 const res = await fetch(window.location.pathname + '?action=continueWorkflow', {
389 method: 'POST',
390 headers: {'Content-Type': 'application/json'},

EEPPortalApp.tsx31 matches

@solomonferede•Updated 59 mins ago
61 const handleLogin = async (username: string, password: string) => {
62 try {
63 const response = await fetch("/login", {
64 method: "POST",
65 headers: { "Content-Type": "application/json" },
407 }
408
409 // --- Fetch Contents
410 if (path === "/fetch-news" && method === "GET") {
411 try {
412 const contents = await sqlite.execute(`
424 });
425 } catch (error) {
426 console.error("Error fetching contents:", error);
427 return new Response(JSON.stringify({ success: false, message: "Failed to fetch contents" }), {
428 status: 500,
429 headers: { "Content-Type": "application/json" },
556 } else {
557 return new Response(
558 JSON.stringify({ success: false, message: "Content updated but could not be refetched" }),
559 {
560 status: 500, // Internal Server Error
625 }
626
627 // Fetch Media
628 if (path === "/fetch-media" && method === "GET") {
629 const mediaEntries = await sqlite.execute(`SELECT * FROM ${KEY}_media_monitored ORDER BY created_at DESC`);
630 return new Response(JSON.stringify({ entries: mediaEntries.rows }), {
749 );
750 } catch (error) {
751 console.error("Failed to fetch detailed report:", error);
752 return new Response(
753 JSON.stringify({ success: false, message: "Failed to fetch detailed report" }),
754 { status: 500, headers: { "Content-Type": "application/json" } },
755 );
931
932 if (result.rowsAffected > 0) {
933 // Fetch the newly created employee to return it with its ID
934 const newEmployeeResult = await sqlite.execute(
935 `SELECT employee_id AS employeeId, user_name AS username, first_name AS firstName, last_name AS fatherName,
1105
1106 if (result.rowsAffected > 0) {
1107 const fetchId = body.employeeId !== undefined ? body.employeeId : originalEmployeeId;
1108 const updatedEmployeeResult = await sqlite.execute(
1109 `SELECT employee_id AS employeeId, user_name AS username, first_name AS firstName, last_name AS fatherName,
1112 address, supervisor_id AS supervisor, created_at, updated_at
1113 FROM ${KEY}_employees WHERE employee_id = ?`,
1114 [fetchId],
1115 );
1116 return new Response(
1147 }
1148
1149 // Fetch Employee by ID
1150 if (path.startsWith("/fetch-employee/") && method === "GET") {
1151 try {
1152 const employeeId = path.split("/").pop();
1172 }
1173 } catch (error) {
1174 console.error("Error fetching employee:", error);
1175 return new Response(
1176 JSON.stringify({ success: false, message: "An error occurred while fetching employee data." }),
1177 { status: 500, headers: { "Content-Type": "application/json" } },
1178 );
1180 }
1181
1182 // Fetch All Employees
1183 if (path === "/fetch-employees" && method === "GET") {
1184 try {
1185 const employees = await sqlite.execute(
1195 );
1196 } catch (error) {
1197 console.error("Error fetching all employees:", error);
1198 return new Response(
1199 JSON.stringify({ success: false, message: "Failed to fetch employees." }),
1200 { status: 500, headers: { "Content-Type": "application/json" } },
1201 );
1313
1314 // --- DEBUGGING LOGS START ---
1315 console.log(`[DEBUG] Fetching tasks for User ID: ${userId}, Role: ${userRole}`);
1316 console.log(`[DEBUG] Status Filter: ${statusFilter}, Assignee Filter: ${assigneeFilter}`);
1317 // --- DEBUGGING LOGS END ---
1377 });
1378 } catch (error) {
1379 console.error("Error fetching tasks:", error);
1380 return new Response(JSON.stringify({ success: false, message: "Failed to fetch tasks" }), {
1381 status: 500,
1382 headers: { "Content-Type": "application/json" },
1407 });
1408 } catch (error) {
1409 console.error("Error fetching single task:", error);
1410 return new Response(JSON.stringify({ success: false, message: "Database error fetching task." }), {
1411 status: 500,
1412 headers: { "Content-Type": "application/json" },
1722 }
1723
1724 // Fetch Comments
1725 if (path === "/fetch-comments" && method === "GET") {
1726 try {
1727 const contentId = url.searchParams.get("content_id"); // Optional: fetch for specific content
1728 let query = `
1729 SELECT
1747 });
1748 } catch (error) {
1749 console.error("Error fetching comments:", error);
1750 return new Response(JSON.stringify({ success: false, message: "Failed to fetch comments" }), {
1751 status: 500,
1752 headers: { "Content-Type": "application/json" },

FetchBasic2 file matches

@ther•Updated 2 days ago

GithubPRFetcher

@andybak•Updated 5 days ago