I’m new to front end dev and especially to reactjs and I’m trying to fetch json data with this code, but I’m having this in console Uncaught (in promise) ReferenceError: response is not defined
Could u help please?
import { useEffect } from "react";
const URL_API = "https://gist.githubusercontent.com/saniyusuf/406b843afdfb9c6a86e25753fe2761f4/raw/523c324c7fcc36efab8224f9ebb7556c09b69a14/Film.JSON";
function App() {
const searchMovies = async (Title) => {
const response = await fetch(`${URL_API}&s=${Title}`);
const data = await response.json();
console.log(data);
};
useEffect(() => {
searchMovies('Avatar');
}, []);
return <h1>hello</h1>;
}
export default App;
2
Answers
we need more context but u can handle errors this way :