1
2
3
4
5
6
7
8
9
10
11
12
import { shortenURL } from "https://esm.town/v/vladimyr/dubShortenURL";
import { fetchVal } from "https://esm.town/v/vladimyr/fetchVal";
import { newValURL } from "https://esm.town/v/vladimyr/newValURL";
const { code } = await fetchVal("vladimyr", "newValURL");
const valURL = newValURL(code);
console.log(valURL.href);
// ==> https://www.val.town/new?code64=aW1wb3J0IHsgYmFzZTY0IGFzIGI2NCB9IGZyb20gIm5wbTptdWx0aWZvcm1hdHMvYmFzZXMvYmFzZTY0IjsKCmV4cG9ydCBmdW5jdGlvbiBuZXdWYWxVUkwoY29kZTogc3RyaW5nLCBiYXNlNjQgPSB0cnVlKSB7CiAgY29uc3QgdXJsID0gbmV3IFVSTCgiaHR0cHM6Ly93d3cudmFsLnRvd
const expiringShortURL = await shortenURL(valURL);
console.log(expiringShortURL.href);
// ==> https://dub.sh/<key>
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
March 8, 2024