Custom app launcher, browser home page, and service monitor. cute.haus
homelab react typescript
0

Configure Feed

Select the types of activity you want to include in your feed.

server: add basic error handling for weather

Aly Raffauf (Jan 30, 2026, 8:15 PM EST) 0895325b f643c3e9

+24 -17
+24 -17
src/index.ts
··· 93 93 const lat = url.searchParams.get("lat"); 94 94 const lon = url.searchParams.get("lon"); 95 95 96 - const pointsResponse = await fetch( 97 - `https://api.weather.gov/points/${lat},${lon}`, 98 - { 99 - headers: { 100 - "User-Agent": "(watsup, aly@aly.codes)", 96 + try { 97 + const pointsResponse = await fetch( 98 + `https://api.weather.gov/points/${lat},${lon}`, 99 + { 100 + headers: { 101 + "User-Agent": "(watsup, aly@aly.codes)", 102 + }, 101 103 }, 102 - }, 103 - ); 104 + ); 104 105 105 - const pointsData = await pointsResponse.json(); 106 - const forecastUrl = pointsData.properties.forecast; 107 - const forecastResponse = await fetch(forecastUrl); 108 - const forecastData = await forecastResponse.json(); 106 + const pointsData = await pointsResponse.json(); 107 + const forecastUrl = pointsData.properties.forecast; 108 + const forecastResponse = await fetch(forecastUrl); 109 + const forecastData = await forecastResponse.json(); 109 110 110 - const location = pointsData.properties.relativeLocation.properties; 111 + const location = pointsData.properties.relativeLocation.properties; 111 112 112 - return Response.json({ 113 - ...forecastData.properties.periods[0], 114 - city: location.city, 115 - state: location.state, 116 - }); 113 + return Response.json({ 114 + ...forecastData.properties.periods[0], 115 + city: location.city, 116 + state: location.state, 117 + }); 118 + } catch (e) { 119 + return Response.json( 120 + { error: "Weather unavailable" }, 121 + { status: 502 }, 122 + ); 123 + } 117 124 }, 118 125 }, 119 126