GIVE ME TEA
0
冰茶.js
35 lines 763 B view raw
1const weather_to_drink_temp_map = { 2 '0': "正常冰", 3 '1': "正常冰", 4 '2': "少冰", 5 '3': "少冰", 6 '71': "熱", 7 '73': "熱", 8 '75': "熱", 9 '77': "熱", 10 '95': "熱", 11 '96': "熱", 12 '99': "熱", 13} 14 15function 要冰(天氣) { 16 if (weather_to_drink_temp_map[天氣]) return weather_to_drink_temp_map[天氣]; 17 else return "溫"; 18} 19 20const BASE_URL = "https://api.open-meteo.com/v1/forecast?current_weather=true&" 21 22Deno.serve(async (req) => { 23 const url = new URL(req.url); 24 25 const latitude = "latitude=25.0330" 26 const longitude = "longitude=121.5654" 27 const 天氣 = await (await fetch(BASE_URL + latitude + "&" + longitude)).json() 28 29 console.log(天氣) 30 31 let resp = "not found" 32 resp = 要冰(天氣); 33 34 return new Response(resp); 35});