You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
780 B
28 lines
780 B
// 常量
|
|
export const NWS_API_BASE = "https://api.weather.gov";
|
|
export const USER_AGENT = "weather-app/1.0";
|
|
|
|
export async function makeNWSRequest(url) {
|
|
const headers = {
|
|
// "User-Agent": USER_AGENT,
|
|
// Accept: "application/geo+json",
|
|
};
|
|
try {
|
|
const response = await fetch(url);
|
|
if (!response.ok) throw new Error("API request failed");
|
|
return await response.json();
|
|
} catch (error) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
export function formatAlert(feature) {
|
|
const props = feature.properties;
|
|
return `
|
|
Event: ${props.event || "Unknown"}
|
|
Area: ${props.areaDesc || "Unknown"}
|
|
Severity: ${props.severity || "Unknown"}
|
|
Description: ${props.description || "No description available"}
|
|
Instructions: ${props.instruction || "No specific instructions provided"}
|
|
`;
|
|
}
|
|
|