1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { octopusAgilePricing } from "https://esm.town/v/MattieTK/octopusAgilePricing";
export async function laMetricOctopus(req: Request) {
const searchParams = new URL(req.url).searchParams;
let location = searchParams.get("location");
if (location == null || location.length < 1) {
return Response.json({
"frames": [
{
"text": `Set location in app`,
"icon": 95,
},
],
});
}
console.log(location);
const currentData = await octopusAgilePricing(
location,
);
if (currentData?.value_inc_vat !== undefined) {
return Response.json({
"frames": [
{
"text": `${currentData.value_inc_vat.toFixed(2).toString()}p`,
"icon": 95,
},
],
});
}
else
console.log("Error:", currentData);
return Response.json({
"frames": [
{
"text": `error`,
"icon": 95,
},
],
});
}