From b4167d2b45a7c193be5e40939444b37f04d6d877 Mon Sep 17 00:00:00 2001 From: Braeden Sowinski Date: Wed, 18 May 2022 12:09:21 -0700 Subject: [PATCH] fix/clean url and api usage --- script.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/script.js b/script.js index 7fa8a9b..ffb1882 100644 --- a/script.js +++ b/script.js @@ -4,7 +4,7 @@ const API_URL = "https://api.opencagedata.com/geocode/v1/json" let weather = { apiKey: API_KEY, fetchWeather: function (city) { - fetch(`https://api.openweathermap.org/data/2.5/weather?q=${city}&units=metric&appid=${this.appkey}`) + fetch(`https://api.openweathermap.org/data/2.5/weather?q=${city}&units=metric&appid=${this.apikey}`) .then((response) => { // error part if it fails if (!response.ok) { alert("No weather found."); @@ -51,8 +51,10 @@ let forcast = { } let geocode = { + apiKey: "5333f43e8a7a4553abee4745425cae8b", + apiURL: API_URL, reverseGeocode: function (latitude, longitude) { - var request_url = `${API_URL}?key=${API_KEY}&q=${encodeURIComponent(latitude+","+longitude)}&pretty=1&no_annotations=1` + var request_url = `${this.apiURL}?key=${this.apiKey}&q=${encodeURIComponent(latitude+","+longitude)}&pretty=1&no_annotations=1` // see full list of required and optional parameters: // https://opencagedata.com/api#forward