Back

Version 7

9/24/2024
import { blob } from "https://esm.town/v/std/blob";

export default async function(req: Request): Promise<Response> {
const searchParams = new URL(req.url).searchParams;
const query = searchParams.get("count");
const length = query && parseInt(query) ? parseInt(query) : 1;
const data = await blob.getJSON("allmaps.json") as Object[];
const max = data.length;
const getRandomInt = () => Math.floor(Math.random() * max - 1);
const resp = Array.from({ length }, () => data[getRandomInt()]);
return Response.json(resp);
}
sammeltassen-allmaps.web.val.run
Updated: December 15, 2024