Axios API is a bit different from the jQuery AJAX one. If you have to pass some params along with GET request, you need to use params property of config object (the second param of .get() method):

axios.get('/api/updatecart', {
  params: {
    product: this.product
  }
}).then(...)

You can pass either a plain object or a URLSearchParams object as params value.

Note that here we're talking about params appended to URL (query params), which is explicitly mentioned in the documentation.

If you want to send something within request body with GET requests, params won't work - and neither will data, as it's only taken into account for PUT, POST, DELETE, and PATCH requests. There're several lengthy discussions about this feature, and here's the telling quote:

Unfortunately, this doesn't seem to be an axios problem. The problem seems to lie on the http client implementation in the browser javascript engine.

According to the documentation and the spec XMLHttpRequest ignores the body of the request in case the method is GET. If you perform a request in Chrome/Electron with XMLHttpRequest and you try to put a json body in the send method this just gets ignored.

Using fetch which is the modern replacement for XMLHtppRequest also seems to fail in Chrome/Electron.

Until it's fixed, the only option one has within a browser is to use POST/PUT requests when data just doesn't fit into that query string. Apparently, that option is only available if corresponding API can be modified.

However, the most prominent case of GET-with-body - ElasticSearch _search API - actually does support both GET and POST; the latter seems to be far less known fact than it should be. Here's the related SO discussion.

Answer from raina77ow on Stack Overflow
Top answer
1 of 1
177

Axios API is a bit different from the jQuery AJAX one. If you have to pass some params along with GET request, you need to use params property of config object (the second param of .get() method):

axios.get('/api/updatecart', {
  params: {
    product: this.product
  }
}).then(...)

You can pass either a plain object or a URLSearchParams object as params value.

Note that here we're talking about params appended to URL (query params), which is explicitly mentioned in the documentation.

If you want to send something within request body with GET requests, params won't work - and neither will data, as it's only taken into account for PUT, POST, DELETE, and PATCH requests. There're several lengthy discussions about this feature, and here's the telling quote:

Unfortunately, this doesn't seem to be an axios problem. The problem seems to lie on the http client implementation in the browser javascript engine.

According to the documentation and the spec XMLHttpRequest ignores the body of the request in case the method is GET. If you perform a request in Chrome/Electron with XMLHttpRequest and you try to put a json body in the send method this just gets ignored.

Using fetch which is the modern replacement for XMLHtppRequest also seems to fail in Chrome/Electron.

Until it's fixed, the only option one has within a browser is to use POST/PUT requests when data just doesn't fit into that query string. Apparently, that option is only available if corresponding API can be modified.

However, the most prominent case of GET-with-body - ElasticSearch _search API - actually does support both GET and POST; the latter seems to be far less known fact than it should be. Here's the related SO discussion.

🌐
Stack Overflow
stackoverflow.com › questions › 70321577 › is-it-possible-to-send-a-get-request-with-json-body-in-axios
reactjs - Is it possible to send a get request with JSON body in Axios? - Stack Overflow
December 12, 2021 - const data: { ... }; // your payload, replace (...) for actual data const config: AxiosRequestConfig = { data }; axios.get('/your-endpoint', config); ... Sign up to request clarification or add additional context in comments.
Discussions

How can I add raw data body to an axios request?
I am trying to communicate with an API from my React application using Axios. I managed to get the GET request working, but now I need a POST one. I need the body to be raw text, as I will write a... More on stackoverflow.com
🌐 stackoverflow.com
axios post request with json data
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 ... Sign up to request clarification or add additional context in comments. ... This was just what I needed. :) 2019-07-26T18:58:56.967Z+00:00 ... You don't need to stringify your payload. Axios ... More on stackoverflow.com
🌐 stackoverflow.com
axios get request with body and header - javascript
In general there is no point in a body for GET requests, so axios does not support it. More on stackoverflow.com
🌐 stackoverflow.com
Axios Post Request Help! When I use Get request, it works perfectly fine though. Essentially, when I make a post request using axios, there is no data that is being passed through. I tried even setting the data param to Id: "string", and even that didn't pass through as im getting undefined.
Axios POST default content type is application/x-www-form-urlencoded and your backend is probably expecting JSON. Change your frontend to send JSON. More on reddit.com
🌐 r/reactjs
4
1
March 18, 2023
🌐
GitHub
github.com › axios › axios › issues › 787
GET request does not send data (JSON). · Issue #787 · axios/axios
March 24, 2017 - axios.get("/api/v1/post/allFromUser", ... console.log(err); }) When I switch this to POST the data get's send just find, but there is no body when sent with GET....
Author   ghost
🌐
Mastering JS
masteringjs.io › tutorials › axios › json
How to Use JSON with Axios - Mastering JS
April 21, 2021 - const axios = require('axios'); ... request, Axios will automatically parse the data to JSON, provided you are sending an object, and make the necessary adjustments elsewhere in the request so it can be automatically parsed once received by the server...
🌐
RapidAPI
rapidapi.com › guides › axios-different-data-formats
How to use Axios with different data formats?
In this section, we'll look at how to send and receive HTTP requests using Axios and JSON data, as well as how to handle response data in JavaScript. To send a GET request with Axios and JSON data, use the axios.get() method and pass in the ...
🌐
GitHub
github.com › axios › axios
GitHub - axios/axios: Promise based HTTP client for the browser and node.js · GitHub
6 hours ago - The request has an unexpected format or is missing required parameters. Usually related to a response with 4xx status code. The default behavior is to reject every response that returns with a status code that falls out of the range of 2xx and treat it as an error. axios.get("/user/12345").catch(function (error) { if (error.response) { // The request was made and the server responded with a status code // that falls out of the range of 2xx console.log(error.response.data); console.log(error.response.status); console.log(error.response.headers); } else if (error.request) { // The request was ma
Starred by 109K users
Forked by 11.6K users
Languages   JavaScript 86.1% | TypeScript 11.9% | HTML 2.0%
🌐
Mastering JS
masteringjs.io › tutorials › axios › response-body
Get the HTTP Response Body with Axios - Mastering JS
July 23, 2020 - const axios = require('axios'); const res = await axios.get('https://httpbin.org/get', { params: { answer: 42 } }); res.constructor.name; // 'Object', means `res` is a POJO // `res.data` contains the parsed response body res.data; // { args: { answer: 42 }, ... } res.data instanceof Object; // true · An Axios response contains several other properties, like status, which contains the HTTP response status code (like 200 or 404). But most of the time you don't care about the response code if the request succeeded, so you will often see code that gets the response body directly using promise chaining.
Find elsewhere
🌐
LogRocket
blog.logrocket.com › home › axios in javascript: how to make get, post, put, and delete requests
Axios in JavaScript: How to make GET, POST, PUT, and DELETE requests - LogRocket Blog
April 9, 2025 - This code instructs Axios to send a POST request to /login with an object of key-value pairs as its data. Axios will automatically convert the data to JSON and send it as the request body.
🌐
Mastering JS
masteringjs.io › tutorials › axios › get-with-data
Axios GET with Data - Mastering JS
September 8, 2020 - So most HTTP services don't support GET request bodies. Instead of sending your data using the data parameter, you can use the params option to tell Axios to put your parameters in the query string:
🌐
Mastering JS
masteringjs.io › tutorials › axios › post-json
POST JSON with Axios - Mastering JS
June 12, 2020 - This means you normally don't have ... want to send as JSON, be careful. If you pass a string to axios.post(), Axios treats that as a form-encoded request body....
🌐
RapidAPI
rapidapi.com › guides › request-body-axios
How to send the request body using Axios?
October 31, 2022 - Loading · Follow us · Product · Build APIs · Public API Hub · API Hub for Enterprise · Rapid API Client VSCode · Enterprise · Internal Hub · Partner Hub
🌐
CircleCI
circleci.com › blog › making-http-requests-with-axios
Making HTTP requests with Axios - CircleCI
May 19, 2022 - Considering that this is a GET request, you do not need to pass a body with a request. Next I will show you how to do that in a POST request using Axios. A POST request is a little different because you often need to pass some data in the request ...
🌐
Reddit
reddit.com › r/reactjs › axios post request help! when i use get request, it works perfectly fine though. essentially, when i make a post request using axios, there is no data that is being passed through. i tried even setting the data param to id: "string", and even that didn't pass through as im getting undefined.
r/reactjs on Reddit: Axios Post Request Help! When I use Get request, it works perfectly fine though. Essentially, when I make a post request using axios, there is no data that is being passed through. I tried even setting the data param to Id: "string", and even that didn't pass through as im getting undefined.
March 18, 2023 -

Front

import React from 'react'
import { useState } from 'react'
import Sidebar from './sidebar/Sidebar'
import Axios from 'axios'
import './gui.css'
const sideBar3Dark = {
height : '100vh',
width : '82.5vw',
backgroundColor : '#161818',
marginLeft: '17.5vw'
}
function HomeGui() {
const [newAboutUs, setVal] = useState("");
const handleSubmit = (e) => {
e.preventDefault();
/*
Axios.get('http://localhost:4000/api/get/aboutUs').then(res => {
console.log(res);
})
*/
Axios.post('http://localhost:4000/api/post', { Id: newAboutUs }).then(res => console.log(res)).catch(err => console.log(err));
  }
return (
<div className='homeGui'>
<form onSubmit={ handleSubmit }>
<input type="text" value = {newAboutUs} onChange={(e) => {setVal(e.target.value)}}/>
<button></button>
</form>
</div>
  )
}
function Gui() {
const [contentStyle, setContentStyle] = useState(sideBar3Dark)
return (
<>
<div className='gui'>
<Sidebar changeStyle={(size) => {setContentStyle(size)}} />
<div className='mainGui' style={ contentStyle }>
<HomeGui/>
</div>
</div>
</>
  )
}
export default Gui

Backend

const express = require('express');
const app = express();
const bodyParser = require("body-parser");
const cors = require('cors');
const fs = require('fs');
app.use(cors());
app.use(bodyParser.urlencoded({ extended: true }));
app.get("/api/get/aboutUs", (req, res) => {
fs.readFile('../client/src/data/aboutUs.json', 'utf-8', (err, jsonString) => {
if (err) {
console.log(err);
} else {
try {
const data = JSON.parse(jsonString);
console.log(data);
res.send(data);
} catch(err) {
console.log(err);
}
}
});
});
app.post("/api/post", (req, res) => {
console.log(req.body.Id);
});
app.listen(4000, () => {
console.log('PORT 4000 connected');
});
Essentially at when I perform console.log(req.body.Id) in app.post(...), it just says undefined in my console, but I do not know why.

🌐
ZetCode
zetcode.com › javascript › axios
Axios Tutorial - Simplifying HTTP Requests
$ node main.js # of followers: 324 Location: Bratislava · A POST request is created with post method. Axios automatically serializes JavaScript objects to JSON when passed to the post function as the second parameter; we do not need to serialize POST bodies ...
🌐
Apidog
apidog.com › blog › axios-get-with-body-and-header
How to make Axios API GET Request with Body and Headers
February 4, 2026 - If you find yourself needing to ... GET requests, it’s important to understand that the HTTP specification typically does not include a request body for GET requests....