val-town / val-town-docs

Val Town Documentation
https://docs.val.town/
31 stars 31 forks source link

Add interactive samples in the REST API section #146

Open pomdtr opened 7 months ago

pomdtr commented 7 months ago

This makes uses of the vt-playground web components.

image

I found out multiple broken vals while editing the examples, so I updated them.

I would advise to only import fetchJSON in the api examples. Wrapping the logic in other vals makes a lot of example useless. ex:


import { alias } from "https://esm.town/v/neverstew/alias";

export let aliasExample = alias({ //
  username: "stevekrouse",
});

This example requires you to read the neverstew/alias val, so I converted it to:

import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";

console.log(await fetchJSON("https://api.val.town/v1/alias/stevekrouse"));