1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { fetch } from "https://esm.town/v/std/fetch";
// when a request comes in fetch hpotter data
export async function harryPotterData(req: express.Request, res) {
try {
const responseData = await fetch(
"https://hp-api.onrender.com/api/characters",
);
const data = await responseData.json();
res.json(data);
}
catch (e) {
res.status(500).send("Internal Server Error");
}
}