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

129
Visualizações
Difference between jQuery and Axios PUT request

I am new to web development and I am working with a system that needs overhauling and development.

I am attempting to pull what is saved on a server as a "JSON" file to the front end and display the encoded data.

The "JSON" file includes text like the following:

{"name": "7.8-15.6kHz",data: [  [Date.UTC(2021, 9, 29, 0, 30, 12),0], [Date.UTC(2021, 9, 29, 0, 30, 12),0], [Date.UTC(2021, 9, 29, 1, 30, 59),0], [Date.UTC(2021, 9, 29, 2, 30, 17),0], [Date.UTC(2021, 9, 29, 3, 30, 15),0],

EDIT: I put "JSON" in quotes because this isn't json, however the file I am grabbing has a .json extension. This is the output of a microprocess somebody else wrote, and I am hoping to use this "JSON" file to pull data on the front end without having to manipulate the microprocess.

This obviously includes Javascript objects (passed as strings via php), as well as strings, and integers.

When I request this data via jQuery, the response is formatted as a Javascript object without needing to do anything to the response:

$.ajax({url:dataHTTP,
     dataType: "json",
     type:"POST",
     data:user,
     success:function(returnedData){
          console.log(returnedData)
          //Do some stuff with returnedData
}})

As I am migrating to REACT, I am trying to achieve the same with Axios:

const config = {
     headers: {
          'content-type': 'application/json'
     }
 }
axios({
     method: 'post',
     url: dataURL,
     data:JSON.stringify(this.state.user),
     headers:config.headers
}).then((res) => {
     console.log(res.data); //this logs a string of the "JSON" file
     JSON.parse(res.data); //this throws an error
      
})

What is the difference here and how can I force Axios to treat this the same way as jQuery does??

about 4 years ago · Juan Pablo Isaza
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