okay so my app is already uploaded
https://wizardly-nobel-49c92b.netlify.com/
but when i try to do a get call in my request .url is
" https://wizardly-nobel-49c92b.netlify.com/api.openweathermap.org/data/2.5/weather?q=burbank&units=metric&APPID=ac520234facdd7bb8b258738bac19fb9 "
but needs to be this
https:/api.openweathermap.org/data/2.5/weather?q=burbank&units=metric&APPID=ac520234facdd7bb8b258738bac19222
i already changed the Environment variables
my axios call
const search = evt => {
if (evt.key === "Enter") {
axios.get(`${api.base}weather?q=${query}&units=metric&APPID=${api.key}`)
.then(response => {
setQuery('');
setWeather(response.data);
setClassName("app " + response.data.weather[0].main)
console.log("hjkgfjgdsjgf", response);
})
.catch(function (error) {
console.log(error);
Swal.fire({
icon: 'error',
title: 'Oops...',
text: 'Make sure location is spelled Correctly',
})
})
}
}
import React, { useState } from 'react';
import axios from 'axios';
import Swal from "sweetalert2";
function App() {
const [query, setQuery] = useState('');
const [weather, setWeather] = useState({});
const [className, setClassName] = useState("app");
const search = evt => {
if (evt.key === "Enter") {
axios.get(`${process.env.REACT_APP_API}weather?q=${query}&units=metric&APPID=${process.env.REACT_APP_API_KEY}`)
.then(response => {
setQuery('');
setWeather(response.data);
setClassName("app " + response.data.weather[0].main)
console.log("hjkgfjgdsjgf", response);
})
.catch(function (error) {
console.log(error);
Swal.fire({
icon: 'error',
title: 'Oops...',
text: 'Make sure location is spelled Correctly',
})
})
}
}
const dateBuilder = (d) => {
let months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
let days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
let day = days[d.getDay()];
let date = d.getDate();
let month = months[d.getMonth()];
let year = d.getFullYear();
return `${day} ${date} ${month} ${year}`
}
return (
<div className={className}>
<main>
<div className="search-box">
<input
type="text"
className="search-bar"
placeholder="Search..."
onChange={e => setQuery(e.target.value)}
value={query}
onKeyPress={search}
/>
</div>
{(typeof weather.main != "undefined") ? (
<div>
<div className="location-box">
<div className="location">{weather.name}, {weather.sys.country}</div>
<div className="date">{dateBuilder(new Date())}</div>
</div>
<div className="weather-box">
<div className="temp">
{Math.round(weather.main.temp * 9 / 5 + 32)}°F
</div>
<div className="weather">
{weather.weather[0].main}
</div>
</div>
</div>
) : (
<div className="start">
Search city to check weather!
</div>
)}
</main>
</div>
);
}
export default App;
never mind i deleted file and re uploaded and it worked