mirror of
https://github.com/Dvorinka/Portfolio.git
synced 2026-06-04 03:42:56 +00:00
first commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
const api_key = "e7704bc895b4a8d2dfd4a29d404285b6";
|
||||
|
||||
export const fetchData = function (URL, callback) {
|
||||
fetch(`${URL}&appid=${api_key}`)
|
||||
.then(res => res.json())
|
||||
.then(data => callback(data));
|
||||
}
|
||||
|
||||
export const url = {
|
||||
currentWeather(lat, lon) {
|
||||
return `https://api.openweathermap.org/data/2.5/weather?${lat}&${lon}&units=metric`
|
||||
},
|
||||
forecast(lat, lon) {
|
||||
return `https://api.openweathermap.org/data/2.5/forecast?${lat}&${lon}&units=metric`
|
||||
},
|
||||
airPollution(lat, lon) {
|
||||
return `https://api.openweathermap.org/data/2.5/air_pollution?${lat}&${lon}`
|
||||
},
|
||||
reverseGeo(lat, lon) {
|
||||
return `https://api.openweathermap.org/geo/1.0/reverse?${lat}&${lon}&limit=5`
|
||||
},
|
||||
/**
|
||||
* @param {string} query Search query e.g.: "London", "New York"
|
||||
*/
|
||||
geo(query) {
|
||||
return `https://api.openweathermap.org/geo/1.0/direct?q=${query}&limit=5`
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user