score:0

Accepted answer

i think your problem is here:

const [searchquery, setsearchquery] = usestate("");

your backend api for fetching event needs an id for it and when every your component mounts to the dom, your useeffect kicks in and calls the api! but meanwhile your state of searchquery is an empty string!

note:

const res = await axios(
  `http://localhost:8080/api/event/${setsearchquery}`
);

you are using setsearchquery in your endpoint string instead of searchquery!

that being said, i think still you will get an error even after changing that bug in your url! because you still send an empty string as id for your backend api!

so the best solution would be to provide a default id for your searchquery in your usestate instead of passing an empty string, or if you cannot provide a default value, make sure that your api does not broke when you providing empty string to it!


Related Query

More Query from same tag