Public
Express
wallek-currencytransaction.express.val.run
October 25, 2023
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { currency } from "https://esm.town/v/stevekrouse/currency?v=23";
// View at https://wallek-currencyTransaction.express.val.run?target=gbp&root=eur&amount=100
export async function currencyTransaction(
req: express.Request,
res: express.Response,
) {
const targetCurrency = String(req.query.target || "gbp");
const rootCurrency = String(req.query.root || "eur");
const amount = Number(req.query.amount || 100);
const c = await currency(
targetCurrency,
rootCurrency,
amount,
);
const text = `${amount} ${rootCurrency.toUpperCase()} = ${c} ${targetCurrency.toUpperCase()}`;
return res.send(`<h1>${text}</h1>`);
}
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!
October 25, 2023