David Choi
David Choi

Reputation: 6619

Reactjs and WebApi post not working

I'm trying to send a post using axios from React into a webapi controller post action. I can see my post action hit, but when I look at the parameter object it has the normal properties but they're all null or 0. I've converted the post params into json string before sending and that has started to at least get me the parameter object's properties but they just go to their defaults.

const params = JSON.stringify({UserID, Configurations{}, ViewName});
axios.post("<path to api>", params);

public void Post([FromBody]UserConfigurationModel Model){
... }

Upvotes: 0

Views: 776

Answers (1)

Jeff McCloud
Jeff McCloud

Reputation: 5927

Try passing your object as is, without stringify'ing it:

const params = {UserID, Configurations, ViewName};
axios.post("<path to api>", params);

Upvotes: 1

Related Questions