score:0
you'll need middleware in order to parse the request and make it accessible in req.body
. i've assumed you're using a version after 4.16 which introduced express.json()
as middleware for this scenario. i'll update my answer if you're using an earlier version.
example using your code as a starter:
const express = require('express');
const app = express();
app.use(express.json());
app.post('/', (req, resp) => {
console.log(request.body.params);
});
app.listen(3000);
to explain, anything you post, aka let's say you posted the following object:
{
fruit: 'apple',
vegetable: 'onion'
}
after using the parser you'd access the posted data in req.body.fruit
and req.body.vegetable
.
score:2
ok, i found the problem. i deleted the axiosconfig from post, based on this source , and now this is the working code:
axios
.post(
"http://localhost:8000/dict/",
{ general: general, onesuggestion: onesuggestion }
)
.then((res) => console.log("success, dictionary sent,", res))
.catch((err) => {
console.log(err.response);
});
thank you guys for your help.
Source: stackoverflow.com
Related Query
- How to send data from react and use the request body in express, using Axios?
- How to send user data and its profile image using POST request from axios api to Django Rest Framework?
- How to send a form input data containing both image and text from React front-end to Express backend using Multer
- How to send array of objects data from child component to parent component and store in the parent object using react hooks?
- how to send data in GET request header using react and axios to Django rest framework?
- How can I cache data that I already requested and access it from the store using React and Redux Toolkit
- How do I correctly add data from multiple endpoints called inside useEffect to the state object using React Hooks and Context API?
- Can I use mock data and proxy api data at the same time in my react project when using node express as a proxy server?
- How to use the useHook in the component rather than passing the value returned from it as a prop to the components using react and typescript?
- How do I send data from react js to backend express (React and Express)
- How to send data and photo at same time to node js backend using axios in react js
- How do I make an axios request using a route parameter from React Router, then update state based on the response?
- take a csv file as input from user using React and send it as a post request using axios
- How to access data outside the function using axios and react js
- How to send data from Modal, Form using react and bootstrap?
- I do not know how to store json data from an api call within a nodejs express server, and send it to a react native client
- using data from GET request in react and use in child component
- How do I render a list from Json data in express js, then render it using react and map()?
- Making an axios get request and using React useState but when logging the data it still shows null
- How to pass input from React Form to Axios get request and display the request result?
- How do I use react context API to pass data from parent component to child component when using react-router in the parent component in React.js?
- How do I use the get request of axios by sending a query from the user and getting the values from the database for that particular query?
- react with TS - using setInterval with useEffect() how to send the request and only then start the interval
- Using react, axios and django, i'm trying to send data from my client side to my server but I can't get the data
- How to concatenate URL and string, and get data from API at click a button using axios in REACT JS
- Pass the fetched data from an API and use it to style buttons using React and Sass
- How to send multiple objects to API and GET the result from API using react js?
- How do I store JWT and send them with every request using react
- CDN links for React packages and how to import it when using react using the scripts from CDN
- How to send body data and headers with axios get request?
More Query from same tag
- How to Add multiple Tracking ID for Google Analytics in Gatsby.js?
- React native flexbox - how to do percentages || columns || responsive || grid etc
- Module not found.Can't resolve '../firebase/config'
- React router not mounting component on redirect in Chrome
- KendoReact Chart panning issue for ChartSeriesItem with map function
- Typescript passing component or DOM tag name
- React hover/active/focus style css selector not working for enclosed element
- nextjs passing data to component
- ReactJS + Apollo Client - Get result without rendering
- React doesn't execute function in component
- React Display Mispelled components in VSCode
- Material dialog showing despite display="none"
- What would be the best way filtering the huge data using Javascript/react/redux
- Next.js app with both Javascript and Typescript
- What is the difference between Routing in React and Express
- How to get the index of the table into columns array in antd table
- Functional component state persistency
- How to update the result on right side based on user input
- Uncaught SyntaxError: Unexpected identifier for import _regeneratorRuntime
- Two Inputs have two states which are dependent on each other
- How can I disappear the Dialog once log out has been performed?
- How to use Redirect in version 5 of react-router-dom of Reactjs
- Updating specific fields in reactJS
- React router links rendered differently on server and client
- Within React, why am I not able to use nested arrow functions... Altough normal functions seem to work?
- Best practice for adding a history subcollection upon submitting the form without cloud functions
- Create seperate render view
- cors failing for subdomains
- Append an object to an array, why does "push" not work?
- Which is the best way to define the type of dynamic data-attributes in a React component?