18
19 try {
20 const response = await fetch("/api/research", {
21 method: "POST",
22 headers: { "Content-Type": "application/json" },
31 }]);
32 } catch (error) {
33 console.error("Error fetching data:", error);
34 setMessages(prev => [...prev, {
35 text: "Sorry, I encountered an error while researching. Please try again.",
4๐ Features
5
6๐ Real-time Weather Data โ Fetches temperature, wind speed, and direction.
7๐ค AI Weather Insights โ Generates creative weather descriptions.
8๐จ Dynamic UI Themes โ Refreshing color schemes for better aesthetics.
42
43 useEffect(() => {
44 async function fetchWeatherAndAI() {
45 try {
46 setLoading(true);
47 // Fetch weather data
48 const weatherResponse = await fetch(
49 `https://api.open-meteo.com/v1/forecast?latitude=${location.latitude}&longitude=${location.longitude}¤t_weather=true&hourly=temperature_2m,relativehumidity_2m,windspeed_10m`
50 );
52 setWeatherData(weatherData);
53
54 // Fetch AI-powered weather insight
55 const { OpenAI } = await import("https://esm.town/v/std/openai");
56 const openai = new OpenAI();
74 setLoading(false);
75 } catch (error) {
76 console.error("Weather fetch or AI generation failed", error);
77 setLoading(false);
78 }
79 }
80
81 fetchWeatherAndAI();
82 }, [location]);
83
189 setError('');
190 try {
191 const response = await fetch(`https://geocoding-api.open-meteo.com/v1/search?name=${input}&count=1&language=en&format=json`);
192 const data = await response.json();
193 if (data.results && data.results.length > 0) {
42
43 useEffect(() => {
44 async function fetchWeatherAndAI() {
45 try {
46 setLoading(true);
47 // Fetch weather data
48 const weatherResponse = await fetch(
49 `https://api.open-meteo.com/v1/forecast?latitude=${location.latitude}&longitude=${location.longitude}¤t_weather=true&hourly=temperature_2m,relativehumidity_2m,windspeed_10m`
50 );
52 setWeatherData(weatherData);
53
54 // Fetch AI-powered weather insight
55 const { OpenAI } = await import("https://esm.town/v/std/openai");
56 const openai = new OpenAI();
74 setLoading(false);
75 } catch (error) {
76 console.error("Weather fetch or AI generation failed", error);
77 setLoading(false);
78 }
79 }
80
81 fetchWeatherAndAI();
82 }, [location]);
83
189 setError('');
190 try {
191 const response = await fetch(`https://geocoding-api.open-meteo.com/v1/search?name=${input}&count=1&language=en&format=json`);
192 const data = await response.json();
193 if (data.results && data.results.length > 0) {
4๐ Features
5
6๐ Real-time Weather Data โ Fetches temperature, wind speed, and direction.
7๐ค AI Weather Insights โ Generates creative weather descriptions.
8๐จ Dynamic UI Themes โ Refreshing color schemes for better aesthetics.
9
10 useEffect(() => {
11 async function fetchWeather() {
12 try {
13 const response = await fetch(
14 `https://api.open-meteo.com/v1/forecast?latitude=${location.lat}&longitude=${location.lon}¤t_weather=true&hourly=temperature_2m,relativehumidity_2m,windspeed_10m`,
15 );
17 setWeather(data);
18 } catch (err) {
19 setError("Could not fetch weather data");
20 }
21 }
22 fetchWeather();
23 }, [location]);
24
72
73 useEffect(() => {
74 fetchTasks();
75 loadUserPreferences();
76 }, []);
99 }
100
101 async function fetchTasks() {
102 try {
103 const response = await fetch("/get-tasks");
104 const data = await response.json();
105 setTaskLists(data);
106 } catch (error) {
107 console.error("Error fetching tasks", error);
108 }
109 }
113
114 try {
115 const response = await fetch("/add-task", {
116 method: "POST",
117 headers: { "Content-Type": "application/json" },
134
135 try {
136 const response = await fetch("/move-task", {
137 method: "POST",
138 headers: { "Content-Type": "application/json" },
152 async function removeTask(taskId, column) {
153 try {
154 const response = await fetch("/delete-task", {
155 method: "POST",
156 headers: { "Content-Type": "application/json" },
169
170 try {
171 const response = await fetch("/move-task", {
172 method: "POST",
173 headers: { "Content-Type": "application/json" },
201 if (!editedTaskText.trim() || !taskBeingEdited) return;
202 try {
203 const response = await fetch("/update-task", {
204 method: "POST",
205 headers: { "Content-Type": "application/json" },
41const api = {
42 get: async (url: string) => {
43 const response = await fetch(url);
44 if (!response.ok) throw new Error("API request failed");
45 return response.json();
46 },
47 post: async (url: string, data: any) => {
48 const response = await fetch(url, {
49 method: "POST",
50 headers: { "Content-Type": "application/json" },
55 },
56 put: async (url: string, data: any) => {
57 const response = await fetch(url, {
58 method: "PUT",
59 headers: { "Content-Type": "application/json" },
64 },
65 delete: async (url: string) => {
66 const response = await fetch(url, { method: "DELETE" });
67 if (!response.ok) throw new Error("API request failed");
68 return response.json();
226
227 useEffect(() => {
228 fetchTodos();
229 loadPreferences();
230 }, []);
234 }, [isDarkMode, visibleFields]);
235
236 const fetchTodos = async () => {
237 try {
238 const data = await api.get("/todos");
239 setTodos(data);
240 } catch (error) {
241 console.error("Error fetching todos:", error);
242 }
243 };
269 try {
270 await api.post("/todos", newTodo);
271 fetchTodos();
272 } catch (error) {
273 console.error("Error adding todo:", error);
278 try {
279 await api.delete(`/todos/${id}`);
280 fetchTodos();
281 } catch (error) {
282 console.error("Error deleting todo:", error);
288 await api.put(`/todos/${editedTodo.id}`, editedTodo);
289 setEditingTodo(null);
290 fetchTodos();
291 } catch (error) {
292 console.error("Error updating todo:", error);
9});
10
11export default lastlogin(vscode.fetch, { verifyEmail });
85 });
86
87 const response = await fetch(
88 `https://maxm-imggenurl.web.val.run/${encodeURIComponent(enhancedPromptText)}?${params}`,
89 );