Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

108
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda