天気のapiを叩いたらCORSでブロックされました。
headerをつければいいという記事を見つけて試してみましたがダメでした。
現在localhostで実行しております。
ちなみにAPIを叩いている場所はstoreのモジュール内です。
どこが間違っているのでしょうか?
js
1 2 const url = 'http://weather.livedoor.com/forecast/webservice/json/v1?city=400040' 3 axios.get(url, 4{'Access-Control-Allow-Origin': 'http://localhost:8080', 'content-type': 'application/json'}) 5 .then(function (response) { 6 console.log(response) 7 }) 8 .catch(function (error) { 9 console.log(error) 10 })
shell
1Access to XMLHttpRequest at 'http://weather.livedoor.com/forecast/webservice/json/v1?city=400040' 2from origin 'http://localhost:8080' has been blocked by CORS policy: 3No 'Access-Control-Allow-Origin' header is present on the requested resource. 4 5xhr.js?ec6c:178 Cross-Origin Read Blocking (CORB) blocked cross-origin response http://weather.livedoor.com/forecast/webservice/json/v1?city=400040 with 6MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 7for more details.
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/01/30 08:13
2019/01/30 08:14