vue-weather-widget
Advanced tools
Comparing version 4.1.0 to 4.2.0
{ | ||
"name": "vue-weather-widget", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"description": "Weather forecast widget for Vuejs using DarkSky api", | ||
@@ -5,0 +5,0 @@ "exportName": "vue-weather-widget", |
@@ -113,3 +113,4 @@ # Vue Weather Widget | ||
| text-color | String | `"#333"` | Color of the text. | | ||
| positionstack-api | String | `"c3bb8aa0a56b21122dea6a2a8ada70c8"` | (optional) You positionstack api key for geocoding. | | ||
| positionstack-api | String | `"c3bb8aa0a56b21122dea6a2a8ada70c8"` | You positionstack api key for geocoding. (Required when using https) | | ||
| ipregistry-key | String | `"f8n4kqe8pv4kii"` | Your ipregistry key to get current location from IP address | | ||
@@ -116,0 +117,0 @@ ## Slots |
@@ -89,2 +89,8 @@ import Utils from "./utils"; | ||
}, | ||
// Your ipregistry key to get location from ip address | ||
ipregistryKey: { | ||
type: String, | ||
default: "f8n4kqe8pv4kii", | ||
}, | ||
}, | ||
@@ -208,3 +214,2 @@ | ||
.catch((err) => { | ||
console.error(err); | ||
this.$set(this, "error", "" + err); | ||
@@ -221,3 +226,3 @@ }) | ||
if (!this.address) { | ||
return Utils.fetchLocationByIP().then((data) => { | ||
return Utils.fetchLocationByIP(this.ipregistryKey).then((data) => { | ||
this.$set(this, "location", { | ||
@@ -224,0 +229,0 @@ lat: data.latitude, |
@@ -52,6 +52,6 @@ import jsonp from "jsonp"; | ||
fetchLocationByIP(ip) { | ||
fetchLocationByIP(apiKey, ip) { | ||
if (!ip) { | ||
return utils.lookupIP().then((data) => { | ||
return utils.fetchLocationByIP(data["ip"]); | ||
return utils.fetchLocationByIP(apiKey, data["ip"]); | ||
}); | ||
@@ -66,3 +66,3 @@ } | ||
const apiKey = "f8n4kqe8pv4kii"; | ||
apiKey = apiKey || "f8n4kqe8pv4kii"; | ||
return fetch(`https://api.ipregistry.co/${ip}?key=${apiKey}`) | ||
@@ -124,3 +124,2 @@ .then((resp) => resp.json()) | ||
else resolve(data); | ||
console.error(err, data); | ||
} | ||
@@ -127,0 +126,0 @@ ); |
38165
522
172