Post request gives "GET" as response.data
See original GitHub issueHi, I’ve been struggling with this for a while and can’t seem to find a solution.
I am sending this request:
//Service
const postPasswordLogin = function (email, password, deviceId, deviceType) {
var data = {email, password, deviceId, deviceType};
return api.post('/sign-in/password', data);
};
//Saga
const response = yield call(api.postPasswordLogin, email, password, 'alibaba', 'android');
console.log(response);
but I keep getting a response like this:
Object
config:Object
data:"GET"
duration:1177
headers:Object
ok:true
problem:null
status:200
if I test the API request with postman using the same JSON object as I see in config and with application/json headers, server responds just fine. With apisause it seems like it’s attempting to send some kind of error (because response header is text/html instead of JSON), but such error won’t have a 200 status code and definitely will have some response…
any ideas?
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
javascript - Make a correct POST request and get response data
And my front-end part of application should send a POST request with a data and get a response. I am trying to use...
Read more >HTTP Methods GET vs POST - W3Schools
HTTP works as a request-response protocol between a client and server. ... GET is used to request data from a specified resource.
Read more >GET vs POST - Difference and Comparison | Diffen
HTTP POST requests supply additional data from the client (browser) to the server in the message body. In contrast, GET requests include all...
Read more >Understanding Axios POST requests - LogRocket Blog
Learn how to use the Axios POST method in both vanilla JavaScript and in a framework like React to send requests.
Read more >POST Request in Postman - Javatpoint
The post is an HTTP method like GET. We use this method when additional information needs to be sent to the server inside...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
ok did some digging around on the server side. in the app I was using the non-www version, which does re-direct to the www. version.
which is fine for GET and apparently it is default behavior to send a GET request to the redirected site instead of sending the same POST request, but to a different URL…
Well, sorry for wasting your time with this, but at least it pointed me in the right direction, I would’ve been looking for this for a while… 😄
The method is set to
post
though.Do you think that your server might be expecting
POST
instead ofpost
?And that URL is the same one you’re using in postman eh?