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

100
Views
axios POST returns 200 but the database does not update

This is my code,it can get the response with 200 but the database doesn't update.The backend told that it had received null.

          axios.post('api/nosql/LineController/insertLine',  {
            line:{
              id:this.id,
              directional:this.directional,
              kilometer:this.slide1.distance,
              runtime:runtime,
              interval:this.slide2.shift,
              type:this.type,
            },
            stationList: this.newPlatforms,
            
          })

And I also tried this code, the problem remained.

        axios({
          method:"post",
          changeOrigin:"true",
          url:"api/nosql/LineController/insertLine",
          transformRequest:[
            function(data){
              return QS.stringify(data);
            }
          ],
          data: {
            line:{
              id:this.id,
              directional:this.directional,
              kilometer:this.slide1.distance,
              runtime:runtime,
              interval:this.slide2.shift,
              type:this.type,
            },
            stationList: this.newPlatforms,
          }
        })

the code at backend

public Object insertLine(HttpServletRequest request) throws IOException {
        StringBuffer lineInfoAndStations = new StringBuffer();
        String line;
        BufferedReader reader;

        reader = request.getReader();
        while(null != (line = reader.readLine())) {
            lineInfoAndStations.append(line);
        }

        return service.addLine(lineInfoAndStations.toString());
    }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

if you use content-type as application/json please remove transformRequest attribute. if you use application/x-www-form-urlencoded ,it can not post array or object to backend

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!