<h1 className="place" id="place">City: {props.data.name}</h1>
?function installWeather(props) {
const request = new Promise((resolve, reject) => {
console.log('Запрос данных на сервер...')
fetch('https://api.openweathermap.org/data/2.5/weather?q=LVIV&units=metric&APPID=5d066958a60d315387d9492393935c19')
.then(response => {
if (response.ok) {
return resolve(response.json());
} else {
reject('Что-то пошло нет так');
}
});
});
request
.then(data => {
return (
<div className='wrapper'>
<div className='container'>
<h1 className="place" id="place">City: {props.data.name}</h1>
<p className="temp" id="temp"></p>
<p className="pressure" id="pressure"></p>
<p className="description" id="description"></p>
<p className="humidity" id="humidity"></p>
<p className="speed" id="speed"></p>
<p className="degree" id="degree"></p>
<img className="image" id="image" src="" alt="clouds" title="Weather"/>
</div>
</div>
)
})
}
export default installWeather;
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
function installWeather(props) {
const request = new Promise((resolve, reject) => {
console.log('Запрос данных на сервер...')
fetch('https://api.openweathermap.org/data/2.5/weather?q=LVIV&units=metric&APPID=5d066958a60d315387d9492393935c19')
.then(response => {
if (response.ok) {
return resolve(response.json());
} else {
reject('Что-то пошло нет так');
}
});
});
return request
.then(data => {
return (
<div className='wrapper'>
<div className='container'>
<h1 className="place" id="place">City: {data.name}</h1>
<p className="temp" id="temp"></p>
<p className="pressure" id="pressure"></p>
<p className="description" id="description"></p>
<p className="humidity" id="humidity"></p>
<p className="speed" id="speed"></p>
<p className="degree" id="degree"></p>
<img className="image" id="image" src="" alt="clouds" title="Weather"/>
</div>
</div>
)
})
}
export default installWeather;