問題
Vue.jsとFirebaseを使ってお天気アプリ作成中にDark Sky APIから値を取ってこようとしたら下記エラーがでた
解決
urlの前にhttps://cors-anywhere.herokuapp.com
をつける
weather-mixin.js
getTemperature() {
this.$axios
.get(
"https://cors-anywhere.herokuapp.com/https://api.darksky.net/forecast/APIキー/37.8267,-122.4233",
{}
)
.then(result => {
console.log("結果", result);
this.temperature = Temperature.create(result);
console.log("temp", this.temperature);
})
.catch(error => {
console.log(error);
});
}
