React/redux: Not Saving In State As Intended
I am building a review app. I am using json-server to do post request. My database looks like this Here is my add Action And here is my reducer Everything works fine. The proble
Solution 1:
Refer to axios document,
axios.post(url[, data[, config]])
in your action thunk,
//...
axios
.post("http://localhost:3004/employees", {
employeeData,
headers: { "Content-Type": "application/json" }
})
//...
you have put the headers: { "Content-Type": "application/json" }
in the data
argument
I guess, what you would do, should be something like this
//...
axios
.post("http://localhost:3004/employees",
employeeData, //data
{ headers: { "Content-Type": "application/json" } } //config
)
// or
axios({
method: 'post',
url: 'http://localhost:3004/employees',
data: employeeData,
headers: { "Content-Type": "application/json" }
})
//...
Post a Comment for "React/redux: Not Saving In State As Intended"