-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dea2152
commit b7f709f
Showing
8 changed files
with
147 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<html lang="en"> | ||
<html lang="es"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" href="http://openweathermap.org/img/wn/[email protected]" /> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,53 @@ | ||
//API KEY - Clave unica del api por usuario | ||
import { API_KEY } from "../utils/constants"; | ||
import * as Request from "../utils/requests"; | ||
|
||
/** | ||
* API Ubicacion por Ip | ||
* @returns { JSON } https://ip-api.com/docs | ||
*/ | ||
export const GetCity = async () => { | ||
try { | ||
|
||
const response = await Request.get('http://ip-api.com/json/?fields=61439') | ||
return response.data; | ||
|
||
} catch (error) { | ||
|
||
throw { | ||
error, | ||
msg:"Fallo - GetCity" | ||
} | ||
|
||
} | ||
} | ||
|
||
/** | ||
* API Clima por ciudad del dia corriente | ||
* @param {String} CITY | ||
* @returns { JSON } https://openweathermap.org/current | ||
*/ | ||
export const GetData = async ( CITY ) => { | ||
const response = await Request.get(`https://api.openweathermap.org/data/2.5/weather?q=${CITY}&units=metric&lang=es&appid=${API_KEY}`) | ||
return response.data; | ||
} | ||
|
||
|
||
export const GetWeekClima = async ( lat, lon ) => { | ||
const response = await fetch(`api.openweathermap.org/data/2.5/forecast?lat=${lat}&lon=${lon}&units=metric&lang=es&appid=${API_KEY}`); | ||
const data = await response.json(); | ||
console.log(data) | ||
return data; | ||
} | ||
|
||
|
||
export const GetClima = async ( callback, city=null ) => { | ||
let dataCiudad = city; | ||
if ( !dataCiudad ) { | ||
let response = await GetCity(); | ||
dataCiudad = response.city; | ||
} | ||
console.log("Data ciudad get clima",dataCiudad); | ||
const data = await GetData(dataCiudad); | ||
callback(data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"status": "success", | ||
"country": "Argentina", | ||
"countryCode": "AR", | ||
"region": "C", | ||
"regionName": "Buenos Aires F.D.", | ||
"city": "Buenos Aires", | ||
"zip": "1871", | ||
"lat": -34.6038, | ||
"lon": -58.3817, | ||
"timezone": "America/Argentina/Buenos_Aires", | ||
"isp": "NSS S.A.", | ||
"org": "", | ||
"as": "AS16814 NSS S.A.", | ||
"query": "190.210.247.53" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
|
||
export const get = async (url) => { | ||
|
||
try{ | ||
|
||
const raw_response = await fetch(url); | ||
const response = await raw_response.json(); | ||
if ( raw_response.status == 200 ) { | ||
return { | ||
code: raw_response.status, | ||
data: response | ||
} | ||
} else if( raw_response.status == 400 ) { | ||
|
||
return{ | ||
code:raw_response.status, | ||
msg_error:"Bad Request" | ||
} | ||
|
||
} | ||
} | ||
catch( error ){ | ||
console.error("Error en Request Get ",error); | ||
} | ||
|
||
} |