Reputation: 13474
In a Meteor method running on server only I wrap a promise as follow:
'my.method'(){
const instance = axios.create({baseURL: 'http://localhost'});
return Promise.await(instance.post('/endpoint', data));
}
It works, but it's a long request (takes a couple of minutes to get the result), and while the request is pending, the app is blocked: I can still click on links and change the route and display other (React) components, but all data flows are interrupted until the request has returned.
Any idea what I am doing wrong?
Upvotes: 3
Views: 72
Reputation: 268
It looks like you want to use this.unblock() inside your meteor method. You can find an in depth explanation here.
'my.method'(){
this.unblock();
const instance = axios.create({baseURL: 'http://localhost'});
Promise.await(instance.post('/endpoint', data));
}
Upvotes: 4