This commit is contained in:
2026-01-26 00:26:20 -03:00
parent 17bb8a15fe
commit 2011d1c969
4 changed files with 32 additions and 15 deletions

View File

@@ -1,7 +1,15 @@
import { log } from "./logger.js"
import { log } from "./logger.js";
import { ErrorResponse, GeoResponse } from "./types.js";
export async function ubicacion(lugar: string, limit = '1') {
const response = await fetch(`${process.env.WEATHER_URL}/geo/1.0/direct?q=${lugar}&limit=${limit}&appid=${process.env.WEATHER_API_KEY}`)
log('GET', response)
return response
export async function ubicacion(lugar: string, limit = '1'): Promise<ErrorResponse | GeoResponse> {
const response = await fetch(`${process.env.WEATHER_URL}/geo/1.0/direct?q=${lugar}&limit=${limit}&appid=${process.env.WEATHER_API_KEY}`);
log('GET', response);
if (!response.ok) {
return {
status: response.status,
message: response.statusText,
};
} else {
return await response.json();
}
}