score:1
Accepted answer
you are destructing a query which are added after a ? in a request. ie .com?cardid=777&value=10000
however in your original code you send it via the post body. change req.query to req.body to achieve the intended result.
router.post('/list/:id', tokencontroller.isavalidtoken, async (req, res) => {
const { cardid, value } = req.body;
console.log(value, cardid); // <- this prints 'undefined'
try {
const orderitem = await orderitemcontroller.createorderitem(value, req.params.id, cardid);
res.json(orderitem);
} catch (error) {
errorcontroller.errorcallback(error, res);
}
});
Source: stackoverflow.com
Related Query
- Parameters not being passed to server router
- State not being passed in React Router v5
- OwnProps not being passed with React Router V4
- Parameters of my function in React child component are not being passed to the parent component's function. Why is this happening?
- Props not being passed through Route element with React Router v6
- Redux state is not being passed to nested router component despite fetching the state directly in that component
- Router state not being persisted in react-native with redux
- Next js and Apollo - Cookie not being passed
- Context not being passed through redux connect()
- React.js pass parameters with Router not in URL
- Ways to fix a child component that is not re-rendering (due to change in data being passed in as props, not state)?
- React router not redirecting on server
- Route not defined react router and spring boot server
- React Router v4 routes with parameters not rendering/refreshing
- Why are my props not being passed into my component when mount rendering?
- React Router v6 redirect when there are not any url queryString parameters
- React Router Switch routes not being matched
- React Router LINK does not pass parameters
- Redux-React: value returned by a dispatch function is not being passed to child component
- React - api data is being successfully passed to component(per inspector) but not being rendered
- Styled-components props being passed but not adapting
- React - Ajax data not being passed into Child Component
- Why value from a Material-UI Button is not being passed to the onClick event handler?
- React Router v4 with Redux - dispatch is not passed
- Link props when passed does not work when browser back and forth is clicked React router v4
- React Router v4 not rendering component in route w/ parameters
- My onChange function is not being passed down to child
- React Router Dom v6 - element with parameters drives me to functions are not valid as a react child
- Kubernetes secrets passed in to React App container but not being used
- Why props is not being passed by history.push?
More Query from same tag
- Updating state adds new objects instead of updating existing objects
- React Typescript: Argument of type '{ [x: number]: any; }' is not assignable to parameter of type
- Material-UI with Next.js & express giving Warning: Prop `className` did not match for server & client
- Missing MaterialUI Table Props in Storybook
- Set State Item Back to Initial State without mutation
- expend rows in Antd table with conditions (Antd 3.26.2)
- Disable Helper Function Not Updating When Changes Are Made
- How do I not include duplicate values in a React state array?
- How to bypass React's error handling of colors
- ReactJS re-render does not reset input fields
- Passing props to reactjs material ui modal
- How to modify nested elements in Radium (or inline CSS) with pseudo selectors?
- React checkbox cannot reset to default unchecked state
- Determining when Relay is fetching query data
- Why is my state's other values being changed to undefined?
- Loop requests in react with axios
- What is useState() in React?
- MUI 5 Autocomplete filtered options count
- adding an object to an array inside an array with useReducer
- customize semantic-ui-react (npm)
- React Router calls component constructor when switching routes
- Parse CSV without download / saving
- Why is the app not re-rendering even if the state has changed?
- Material-UI Data-Grid: How pass parameter to custom toolbar?
- "Uncaught TypeError: Cannot read properties of undefined (reading FetchApi.js:23 'data')" when refresh the page
- Prefetch works but throws an "uncaught (in promise) error"
- Opening modal from click of a different button from parent component
- Use Material UI autocomplete in freeSolo mode with react-hook-form
- React component re-rendering even after using memo and useCallback
- Can't use addGraphQLSubscriptions in React, states "Object(...) not defined)"