comits
This commit is contained in:
18
src/clima.ts
18
src/clima.ts
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user