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/$1?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 10806 results for "fetch"(710ms)

Send Discord message via webhook125 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, }: {

Proxied fetch207 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

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 result

Send messages to Slack247 words

https://docs.val.town/integrations/slack/send-messages-to-slack/
as a Val Town environment variable as slackWebhookURL. Use fetch to send a message. Translate the sample cURL request to a fetch request. You can run the following val: Send

Sections

Use fetch to send a message

Use fetch to send a message. Translate the sample cURL request to a fetch request. You can run the following val: Send messageRun in Val Town ↗ const res =

Google Sheets1211 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. In your val, fetch a fresh Google Sheets access token

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. In your val, fetch a fresh Google Sheets access token from Pipedream and use it to authenticate

Early Return456 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); } }

Github user's stars (pagination)426 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 scraping416 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

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

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; };

Express402 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({

Browserless402 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: [

blob_adminmain.tsx1 match

@codeanand•Updated 12 mins ago
199});
200
201export default lastlogin((request: Request) => app.fetch(request));

blob_adminapp.tsx22 matches

@codeanand•Updated 12 mins ago
231 const [isDragging, setIsDragging] = useState(false);
232
233 const fetchBlobs = useCallback(async () => {
234 setLoading(true);
235 try {
236 const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
237 const data = await response.json();
238 setBlobs(data);
239 } catch (error) {
240 console.error("Error fetching blobs:", error);
241 } finally {
242 setLoading(false);
245
246 useEffect(() => {
247 fetchBlobs();
248 }, [fetchBlobs]);
249
250 const handleSearch = (e) => {
261 setBlobContentLoading(true);
262 try {
263 const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
264 const content = await response.text();
265 setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
266 setEditContent(content);
267 } catch (error) {
268 console.error("Error fetching blob content:", error);
269 } finally {
270 setBlobContentLoading(false);
275 const handleSave = async () => {
276 try {
277 await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
278 method: "PUT",
279 body: editContent,
287 const handleDelete = async (key) => {
288 try {
289 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
290 setBlobs(blobs.filter(b => b.key !== key));
291 if (selectedBlob && selectedBlob.key === key) {
304 const key = `${searchPrefix}${file.name}`;
305 formData.append("key", encodeKey(key));
306 await fetch("/api/blob", { method: "POST", body: formData });
307 const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
308 setBlobs([newBlob, ...blobs]);
312 }
313 }
314 fetchBlobs();
315 };
316
326 try {
327 const fullKey = `${searchPrefix}${key}`;
328 await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
329 method: "PUT",
330 body: "",
341 const handleDownload = async (key) => {
342 try {
343 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
344 const blob = await response.blob();
345 const url = window.URL.createObjectURL(blob);
360 if (newKey && newKey !== oldKey) {
361 try {
362 const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
363 const content = await response.blob();
364 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
365 method: "PUT",
366 body: content,
367 });
368 await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
369 setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
370 if (selectedBlob && selectedBlob.key === oldKey) {
380 const newKey = `__public/${key}`;
381 try {
382 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
383 const content = await response.blob();
384 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
385 method: "PUT",
386 body: content,
387 });
388 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
389 setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
390 if (selectedBlob && selectedBlob.key === key) {
399 const newKey = key.slice(9); // Remove "__public/" prefix
400 try {
401 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
402 const content = await response.blob();
403 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
404 method: "PUT",
405 body: content,
406 });
407 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
408 setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
409 if (selectedBlob && selectedBlob.key === key) {

HN-fetch-call2 file matches

@ImGqb•Updated 9 hours ago
fetch HackerNews by API

FRAMERFetchBasic1 file match

@bresnik•Updated 1 day ago