DEV Community

POST request in redux-saga not working

Sai Avinash Duddupudi on January 21, 2021

I would like to make post request in redux-saga. My code looks like: var formdata = new FormData(); formdata.append("points", "a,b"); for...
Collapse
 
saiavinashiitr profile image
Sai Avinash Duddupudi • Edited

Update :- The 400 Bad request has gone away after I added "Content-Type": "application/x-www-form-urlencoded" in the headers and changed the body type accordingly

Example :-

fetch("api/xxx", {
    body: "email=test@example.com&password=pw",
    headers: {
        "Content-Type": "application/x-www-form-urlencoded",
    },
    method: "post",
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
kriscannabis profile image
Pavel Slobozhaninov

body : JSON.stringify(formdata)