Public
Script
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { fetch } from "https://esm.town/v/std/fetch";
export let jsYAMLExample = (async () => {
// Import the YAML parser
const jsYaml = await import("npm:js-yaml");
// Fetch a YAML file
const yaml = await fetch(
"https://raw.githubusercontent.com/docker/engine/8955d8da8951695a98eb7e15bead19d402c6eb27/api/swagger.yaml",
).then((r) => r.text());
// parse the fetched file
const obj = jsYaml.load(yaml);
// Return part of the file
return obj.info;
})();
October 23, 2023