182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({
51 const id = path.split("/")[2];
52 if (id && id !== "undefined") {
53 fetchDocument(id);
54 setMode(path.startsWith("/view/") ? "view" : "edit");
55 } else {
59 }, []);
60
61 const fetchDocument = async (id) => {
62 try {
63 const response = await fetch(`/api/document/${id}`);
64 if (!response.ok) {
65 throw new Error(`HTTP error! status: ${response.status}`);
70 setForkId(data.id);
71 } catch (e) {
72 console.error("Error fetching document:", e);
73 setError("Error fetching document. Please try again.");
74 }
75 };
78 e.preventDefault();
79 try {
80 const response = await fetch("/api/document", {
81 method: "POST",
82 headers: { "Content-Type": "application/json" },
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3interface ReactionType {
32 is_big: boolean;
33}) =>
34 fetchJSON(
35 `https://api.telegram.org/bot${botToken}/setMessageReaction`,
36 {
51 const id = path.split("/")[2];
52 if (id && id !== "undefined") {
53 fetchDocument(id);
54 setMode(path.startsWith("/view/") ? "view" : "edit");
55 } else {
59 }, []);
60
61 const fetchDocument = async (id) => {
62 try {
63 const response = await fetch(`/api/document/${id}`);
64 if (!response.ok) {
65 throw new Error(`HTTP error! status: ${response.status}`);
70 setForkId(data.id);
71 } catch (e) {
72 console.error("Error fetching document:", e);
73 setError("Error fetching document. Please try again.");
74 }
75 };
78 e.preventDefault();
79 try {
80 const response = await fetch("/api/document", {
81 method: "POST",
82 headers: { "Content-Type": "application/json" },
15 const { latitude, longitude } = position.coords;
16 setLocation(`${latitude.toFixed(4)}, ${longitude.toFixed(4)}`);
17 fetchWeather(latitude, longitude);
18 }, () => {
19 setLocation("Location not available");
23 }, []);
24
25 const fetchWeather = async (latitude, longitude) => {
26 try {
27 const response = await fetch(`https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}¤t_weather=true`);
28 const data = await response.json();
29 setWeather(`${data.current_weather.temperature}°C, ${getWeatherDescription(data.current_weather.weathercode)}`);
30 } catch (error) {
31 console.error("Error fetching weather:", error);
32 setWeather("Weather data unavailable");
33 }
70 const loadTackleBox = async () => {
71 try {
72 const response = await fetch("/api/tackleBox");
73 if (response.ok) {
74 const data = await response.json();
167 formData.append("image", lureImage);
168 try {
169 const response = await fetch("/api/uploadImage", {
170 method: "POST",
171 body: formData,
185
186 try {
187 const response = await fetch("/api/tackleBox", {
188 method: "POST",
189 headers: {
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({