Пробую React. Запрос на локалке к стороннему api через axios возвращает: Failed to load http://samples.openweathermap.org/data/2.5/weather?appid=4eb78b09ae5168929d6d8e623d13749f&q=Moscow: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. Может кто нибудь на пальцах объяснить как это пофиксить? Делаю запрос к погодному API на React:
var axios = require('axios');
const OPEN_WEATHER_MAP_URL = 'http://samples.openweathermap.org/data/2.5/weather?appid=4eb78b09ae5168929d6d8e623d13749f';
module.exports = {
getTemp: function (location){
var encodedLocation = encodeURIComponent(location);
var requestUrl = `${OPEN_WEATHER_MAP_URL}&q=${encodedLocation}`;
return axios.get(requestUrl).then(function (res) {
if (res.data.cod && res.data.message){
throw new Error(res.data.message);
} else {
return res.data.main.temp;
}
}, function (res){
throw new Error(res.data.message);
});
}
}