It depends on what object does onVote
event from Poll
component pass. But if it’s vote object, that’s required in postPoll method as second arguement, than:
- function in onVote event should pass poll.id from this component and vote object from
Vote
componentonVote
event itself:
onVote={(vote) => handalchange(poll.id, vote)}
- handalchange should fire postPoll api method with these arguements and load updated poll data on success:
const handalchange = (pollId, vote) => {
postPoll(pollId, vote).then(() => {
loadPoll();
});
}
7
solved How can I POST data using API from REACTJS?