score:0
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!
Source: stackoverflow.com
Related Query
- Validation failed for parameter 'id'. Invalid number?
- React: Invalid value for prop `savehere` on <div> tag. Either remove it from the element, or pass a string or number value to keep it in the DOM
- Formik input value for a number becomes a string even after it passes the Formik validation as a number
- bignumber.js@^9.0.1, which was used for Dapp over AWS S3, causes an invalid Big number error. Please teach me how to solve this issue
- Radio button validation in React for dynamic number of radio buttons
- User validation failed: name: Cast to String failed for value
- Order validation failed: personalDetails.gift: Cast to Boolean failed for value "No" at path "personalDetails.gift"
- Combine regex for mobile number validation
- Input Text validation in react for containing at least one character and one number
- Invalid value for prop `logo` on <img> tag. Either remove it from the element, or pass a string or number value to keep it in the DOM
- Set Icon for a button: Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'
- MERN stack: Cast to Number failed for value 'NaN'
- is there any solution to error in nodejs " Cast to Number failed for value "undefined" at path "
- contact validation failed: name: Cast to ObjectId failed for value "sara smith" at path "name"
- React prop validation for date objects
- Warning : Failed child context type: Invalid child context 'virtualizedCell.cellKey' of type 'number' supplied to 'CellRenderer', expected 'string'
- Validation using Yup to check string or number length
- Warning: Failed propType: Invalid prop `component` supplied to `Route`
- TypeError: Failed to execute 'fetch' on 'Window': Invalid value
- Typescript/React what's the correct type of the parameter for onKeyPress?
- Warning: Failed propType: Invalid prop of type `array` expected `object` with React
- Testing with Jest failed with Error: Error watching file for changes: EMFILE
- Get invalid value from input type number
- System limit for number of file watchers reached
- How to assign object validation in yup for react-select (single-select)
- How to write a custom schema validation using yup.addMethod() for country name and code?
- W3C HTML validation for React JSX files
- Exclude a value for a path parameter in React Router by type
- What is the second parameter for in a React functional component?
- redux-form v6 show validation error for select field
More Query from same tag
- How to pass data to {props.children}
- createAsyncThunk - changing the state on pending doesn't cause immediate rerendering
- How to open directly our app in apple store?
- How to customize the margin, padding and fontsize of a TextField
- Can't get mapped array of objects to show in HTML table React
- Posts Page in React js
- Props not being passed down to Material UI button text
- Filter a collection for everything except the values in an array (exclude the values in the array)
- how to show error note for only when a particular object value is empty in text field in reactjs
- How to dispatch an action on page load in react-redux?
- no output in browser, nothing in the console
- How to find reactJS errors?
- How to get React to re fetch my data from API after a POST or DELETE to Database?
- Name of key in React.js for unselectable css
- Struggling for passing React routing param
- Input reset in react
- App that runs locally and builds and deploys on Heroku but shows an application error when I try to open it
- Hot reloading in a React app with express server
- Convert react JSX object to HTML
- Covert a long string to number
- React re-rendering a component on prop update
- Redirect from one page to another in react
- Websocket is undefined immediately after receiving message in react
- Props vs Children to pass HTML content in ReactJS
- Cannot read property 'token' of undefined reactjs Jwt Auth
- Problems updating single product price reactjs/redux
- random button is not working as expected (React)
- Error: React.Children.only expected to receive a single React element child
- Can't load tflite custom model into web using react
- Emotion-Theming and Typescript requires `theme` prop