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

181
Vistas
axios get request with body and header

how can I something like this, sending body params and header with Authorization token into this

enter image description here

const searchByDate = async ({ date1, date2 }) => {
  const tokenApp = window.localStorage.getItem('token');
  const { data: res } = await axios.get(`${baseUrl}/search`, {
    data: { date1: date1, date2: date2 },
    headers: { Authorization: `${tokenApp}` },
  });
  return res;
};

so far it is throwing me an error Required request body is missing

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

0

In general there is no point in a body for GET requests, so axios does not support it.

If you read the axios config documentation, you will find

// data is the data to be sent as the request body
// Only applicable for request methods 'PUT', 'POST', 'DELETE , and 'PATCH'

You can read more at HTTP GET with request body for the reasons.


If you want to send data in a GET request use the params property

// params are the URL parameters to be sent with the request
// Must be a plain object or a URLSearchParams object

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