Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!