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.


Related Query

More Query from same tag