2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Dark Sky APIで値を取ってきたらエラーがでる

Posted at

問題

Vue.jsとFirebaseを使ってお天気アプリ作成中にDark Sky APIから値を取ってこようとしたら下記エラーがでた
スクリーンショット 2020-02-03 14.49.47.png

解決

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);
        });
    }
スクリーンショット 2020-02-13 19.00.39.png
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?