Reputation: 43
I would like to call an API resource using meteor and React. What I would like to happen is;
How do I achieve this? Am I on the right track by using Meteor.wrapAsync?
Upvotes: 0
Views: 96
Reputation: 679
Meteor.wrapAsync wouldn't be neccesary. If you have a button in React. You should keep the fields in the state. React Forms. Then use this code in your component to call a meteor method.
onClick(e){
e.preventDefault();
const { objectToPost } = this.state;
Meteor.call("some_method", objectToPost, (err, res) => { doSmthWithFrontend });
}
The Meteor method will be called async for you and return when the call returns. In this method you can use Meteor Http to achieve what you want.
Upvotes: 1