Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
Can't send data through axios and node back-end

I am trying to access the expression passed from the backend to the frontend through axios.

Producer side:

const axios = require('axios');
const URL = "http://localhost:5000/"
let n1 = 3
let n2 = 5
let sum = n1+n2;



axios.post(URL, JSON.stringify({
    expression: sum,
  }))
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  });

and on the consumer side:

const express = require('express')
const app = express()

app.post('/', (req, res) => {
  console.log(req.body);
})

app.listen(5000, () => console.log())

Ultimately, I would like to have the consumer side log "8"

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

From the "express" documentation:

req.body

Contains key-value pairs of data submitted in the request body. By default, it is undefined, and is populated when you use body-parsing middleware such as body-parser and multer.

Try including this before you try to register the endpoint:

const bodyParser = require('body-parser')

app.use(bodyParser.json())

You can also use express.json() and drop the 'body-parser' dependency:

// const bodyParser = require('body-parser')

app.use(express.json())
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!