Send Discord message via webhook129 words
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 fetch210 words
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
Google Sheets1356 words
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
Web scraping439 words
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); //
Early Return497 words
'/') { // Send off the relevant data to /process below. // This `fetch` is not awaited. fetch(`${req.origin}/process`, { method: "POST", body: req.body, }); // Respond immediately, before the processing
Sections
How to return early, and process after
'/') { // Send off the relevant data to /process below. // This `fetch` is not awaited. fetch(`${req.origin}/process`, { method: "POST", body: req.body, }); // Respond immediately, before the processing
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)436 words
@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: {
Express410 words
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
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: [
Get a Github user196 words
@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; };
Runtime153 words
to environment variables. The experimental Temporal API is enabled. Included environment. Section titled “Included environment” fetch to make HTTP requests. import from npm and https. Custom Types View the custom
Sections
Included environment
Included environment. Section titled “Included environment” fetch to make HTTP requests. import from npm and https. Custom Types View the custom types we support