tikTokVideoDownloadermain.tsx7 matches
11const downloadRef = useRef(null);
1213const fetchTikTokVideo = async () => {
14// Reset previous state
15setDownloadLink('');
20try {
21// Use a more reliable, free TikTok video download service
22const response = await fetch(`https://api.tikmate.app/api/lookup`, {
23method: 'POST',
24headers: {
36setError('');
37
38// Fetch video blob for direct download
39const videoResponse = await fetch(data.download_url);
40const blob = await videoResponse.blob();
41setVideoData(blob);
42} else {
43setError('Could not fetch video. Please check the URL and try again.');
44}
45} catch (err) {
92/>
93<button
94onClick={fetchTikTokVideo}
95style={styles.button}
96disabled={!videoUrl || loading}
104{loading && (
105<div style={styles.loadingSpinner}>
106<span>🔄 Fetching video...</span>
107</div>
108)}
translatormain.tsx4 matches
244const formData = new FormData();
245formData.append("audio", blob, "recording.wav");
246const response = await fetch("/transcribe", { method: "POST", body: formData });
247if (response.ok) {
248const result = await response.text();
284const language2Value = document.getElementById("language2").value;
285286const response = await fetch("/translate", {
287method: "POST",
288headers: { "Content-Type": "application/json" },
326327if (text && voice) {
328const response = await fetch('/generate-speech', {
329method: 'POST',
330headers: { 'Content-Type': 'application/json' },
453});
454455export default app.fetch;
sqlite_adminmain.tsx1 match
10app.get("/", async (c) => c.html(await sqlite_admin_tables()));
11app.get("/:table", async (c) => c.html(await sqlite_admin_table(c.req.param("table"))));
12export default basicAuth(app.fetch, { verifyUser: (_, password) => verifyToken(password) });
getLemmyJwtmain.tsx1 match
7const { LemmyHttp } = await import("npm:lemmy-js-client@0.18.1");
8let client = new LemmyHttp(`https://${instance}`, {
9fetchFunction: fetch,
10});
11try {
102}
103104// Val Town HTTP Endpoint for Airtable → Framer Fetch
105export default async function (req: Request): Promise<Response> {
106// Setup CORS Headers for Framer Fetch compatibility
107const headers = new Headers({
108"Access-Control-Allow-Origin": "*",
123const airtableTableId = await val.secrets.AIRTABLE_TABLE_ID;
124125// Fetch all records with pagination
126let allRecords: AirtableRecord[] = [];
127let offset: string | undefined;
133}
134135const airtableResp = await fetch(url.toString(), {
136headers: {
137Authorization: `Bearer ${airtableApiKey}`,
codeOnValTownmain.tsx3 matches
3738/**
39* @param handler Fetch handler
40* @param val Define which val should open
41*/
42export function modifyFetchHandler(
43handler: (req: Request) => Response | Promise<Response>,
44{ val, style }: { val?: ValRef; style?: string } = {},
52}
5354export default modifyFetchHandler;
codeOnValTownREADME.md6 matches
11Here are 2 different ways to add the "Code on Val Town" ribbon:
1213### 1. Wrap your fetch handler (recommended)
1415```ts
16import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
17import { html } from "https://esm.town/v/stevekrouse/html?v=5";
1819export default modifyFetchHandler(async (req: Request): Promise<Response> => {
20return html(`<h2>Hello world!</h2>`);
21});
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
5253- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`
54- `modifyHtmlString("<html>...", {val: { handle: "andre", name: "foo" }})`
5558You can set the style parameter to a css string to customize the ribbon. Check out [github-fork-ribbon-css](https://github.com/simonwhitaker/github-fork-ribbon-css?tab=readme-ov-file#styling) to learn more about how to style the element.
5960- `modifyFetchHandler(handler, {style: ".github-fork-ribbon:before { background-color: #333; }"})`
61- `modifyHtmlString("<html>...", {style: ".github-fork-ribbon:before { background-color: #333; }"})`
626465```ts
66modifyFetchHandler(handler, {style: `@media (max-width: 768px) {
67.github-fork-ribbon {
68display: none !important;
contentTemplateAppmain.tsx19 matches
5354useEffect(() => {
55fetchContent();
56}, []);
5758const fetchContent = async () => {
59try {
60const response = await fetch("/api/content");
61const data = await response.json();
62if (data.records) {
63setContent(data.records);
64} else {
65throw new Error("Failed to fetch content");
66}
67setLoading(false);
68} catch (error) {
69console.error("Error fetching content:", error);
70setLoading(false);
71}
99const analyzeContent = async (item: AirtableRecord) => {
100try {
101const response = await fetch("/api/analyze", {
102method: "POST",
103headers: {
260261try {
262const response = await fetch(airtableUrl, {
263headers: {
264'Authorization': `Bearer ${apiToken}`,
274return new Response(JSON.stringify(data), { headers });
275} catch (error) {
276console.error("Error fetching Airtable data:", error);
277return new Response(JSON.stringify({ error: "Error fetching data from Airtable" }), {
278status: 500,
279headers
368// Example 2: Making an API call to /api/content endpoint
369/*
370async function fetchContent() {
371try {
372const response = await fetch('https://awhitter-contenttemplateapp.web.val.run/api/content');
373const data = await response.json();
374console.log('Content:', data);
375// Process the data as needed
376} catch (error) {
377console.error('Error fetching content:', error);
378}
379}
380381fetchContent();
382*/
383427*/
428429// Example 5: Using the endpoint in Framer with fetch
430/*
431// In your Framer project, create a new code component and use the following code:
433import { Data, animate, Override, Animatable } from "framer"
434435// This function fetches the content from the API
436async function fetchContent() {
437try {
438const response = await fetch('https://awhitter-contenttemplateapp.web.val.run/api/content')
439const data = await response.json()
440return data.records
441} catch (error) {
442console.error('Error fetching content:', error)
443return []
444}
450451Data.useEffect(() => {
452fetchContent().then(setContent)
453}, [])
454
694695// just launch it, don't wait for the result
696// const taskRunResponse = await fetch(`${URL}/taskrun`, {
697const taskRunResponse = fetch(`${URL}/taskrun`, {
698method: "POST",
699headers: {
785}
786787export default app.fetch;
788export { ai, ModelProvider, modelProvider, test };