Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

130
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda