Back to APIs list
Google Drive API examples & templates
Use these vals as a playground to view and fork Google Drive API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
getNextSSR
@rlesser
Script
getNextSSR - fetch data from Next.js SSR-based sites Many modern websites use Next.js and Server-side Rendering (SSR) to serve their website and the data to populate it. Instead of standard API calls, this manifests in the browser as calls routed through dynamic endpoints. This val handles the url construction and response parsing, giving you access to the endpoint and data. Input websiteUrl - The website's url, like google.com or val.town
let getNextSSR: (websiteUrl: string) => Promise<(endpoint: string) => Promise<Record<string, any>>> Returns fetching function - A function that takes in an endpoint and returns the endpoint's response data: Input endpoint - The endpoint string, like results.json or trending.json?page=2 Returns data - The endpoint response data, without NextJS artifacts. Example const fetch = await @rlesser.getNextSSR("example.com");
const data = fetch("results.json");
return data;
litExample
@tmcw
Script
lit Lit is kind of like Google's answer to React: it's a little more reliant on browser APIs like custom elements and the shadow DOM, a little less 'magic', like using JSX. This is an example of using Lit and rendering it straight to a string, which is something that's recently popular. It works pretty well, right off the bat: Lit provides nice ESM modules and a pretty smooth workflow!
dataUriGenApp
@g
HTTP
* This application creates a client-side data URI generator with the following features:
* - File upload through input and drag-and-drop
* - Automatic MIME type detection
* - Preview of the uploaded file (image, video, audio, or text)
* - Copy button to easily copy the generated data URI
*
* We'll use the FileReader API for file handling and data URI generation.
* The application will be built using HTML, CSS, and JavaScript, served by a Hono app.