question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GET request does not send data (JSON).

See original GitHub issue

Code:

axios.get("/api/v1/post/allFromUser", {data: {"author": "fharding"}}).then(response => {
        this.posts = response.data;
      }).catch(err => {
        alert(err);
        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. Sending JSON with GET is not against spec, why is this not working? I’ve also tried using json.stringify for sending the data.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:60
  • Comments:55 (4 by maintainers)

github_iconTop GitHub Comments

182reactions
amgadserrycommented, Mar 24, 2017

because get requests doesn’t have a body use query params instead

58reactions
caoyuanqicommented, Dec 14, 2017

I think GET is not for sending data. the only way to pass information with GET is in through request parameter.

Read more comments on GitHub >

github_iconTop Results From Across the Web

requests lib post request not sending proper json format data
I am calling this API using postman & it is giving me proper response but when I use Python's requests lib to call...
Read more >
How do I post JSON to the server? - ReqBin
To send JSON data to the server, you need to provide the JSON data in the HTTP POST request body and pass the...
Read more >
Sending POST JSON Requests With Axios - Stack Abuse
In this article, we will learn how to send POST JSON requests with Axios, and how to handle both previously serialized and unserialized...
Read more >
Add a Request Body to a POST Request | API Connector
If your POST request isn't working, a likely cause is a mismatched content type. Try adding in a content type into the header...
Read more >
Quickstart — Requests 2.28.1 documentation
In case the JSON decoding fails, r.json() raises an exception. For example, if the response gets a 204 (No Content), or if the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found