Can someone please tell me why i am getting this error . I tried fixing it all day, but I could not fix it. So at last i had to come at stackoverflow
This is my code : App.js
import "./App.css";
function App() {
const [inputvalue, setInputvalue] = useState(" ");
const [apidata, setApidata] = useState([]);
const [finalpoint, setFinalpoint] = useState("");
useEffect(() => {
fetch(
`https://weatherapi-com.p.rapidapi.com/forecast.json?q=+${inputvalue}&days=3`,
{
method: "GET",
headers: {
"x-rapidapi-host": "weatherapi-com.p.rapidapi.com",
"x-rapidapi-key":
"7f89bf16ebmsh9dff0f23f963d34p190691jsn264543e18108",
},
}
)
.then((response) => {
return response.json();
})
.then((data) => {
setApidata(data);
})
.catch((err) => {
console.error(err);
});
}, [finalpoint]);
const onchangeinput = (e) => {
setInputvalue(e.target.value);
};
const onsubmithandler = (e) => {
e.preventDefault();
setFinalpoint(inputvalue);
};
return (
<div className="App">
<div className="main">
<h2>Welcome To weather App </h2>
</div>
<form onSubmit={onsubmithandler}>
<input type="text" value={inputvalue} onChange={onchangeinput} />
<button type="submit">Search</button>
</form>
{apidata.map((data, i) => {
return <h1>{data.current.feelslike_c}</h1>;
})}
</div>
//Map
);
}
export default App;
This is the error I am getting :
enter image description here