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

298
Vistas
axios post request with json data

I am using Axios JS library for sending post json request. but I am not receiving anything at the server. Here is my code

const dt = JSON.stringify({"data":{"value":"gdfg1df2g2121dgfdg"}});
const request = axios.post(url, {dt});

I need to send post raw body in json format.

about 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

By default axios uses Json for posting data so you don't need to stringify your data. The problem could be that you're doing that. Could you try doing the post without it and check if it works? Also you don't need the curly braces to wrap your data unless that's the format of the object in your server. Otherwise could you give me information about how the body of the request looks like so I have more context? You can check that in chrome dev tools using the network tab

about 4 years ago · Santiago Trujillo Denunciar

0

You don't need to stringify your payload. Axios will do it for you when it it send a request.

const dt = { data: { value: "gdfg1df2g2121dgfdg" }};
const request = axios.post(url, dt);
about 4 years ago · Santiago Trujillo Denunciar

0

Axios for post request with json as its body:

  static async postService(path, data = {}) {
    const requestUrl = HttpRequest._getRequestUrl(path);

    try {
      const ret = await axios.post(requestUrl, JSON.stringify(data));
      console.log('Request result ', ret);
    } catch (error) {
      console.error(`Request error: ${error.message}`);
    }
  }
about 4 years ago · Santiago Trujillo Denunciar
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