How to make a synchronous?

Is it possible to make a synchronous and how?

var Tget = Meteor.wrapAsync(T.get);

  'screenName': function() {
    return Tget({
      q : '#UCLA',
      count : 1

This will make the function on the server side synchronous, right?

But I need itself to be synchronous. I need to get the result from before the process continues to render other stuff… is it possible?

You can use a callback on the client, or (better) you can use async and await on the client with a little effort:

1 Like

Note that these are all just syntax stuff - at the end of the day, no, there’s nothing you can do to make an asynchronous call from the client block everything else. You need to explicitly handle the case before and after data has been returned.


My solution:

const Future = require('fibers/future');
const createCustomer = function(userId) {
  const future = new Future();'stripeCreateCustomer', userId, function(err, customer) {
    if(err) return orbiter.core.throwError(err);
  return future.wait();

let customer = user.stripe?.customer;
if(!customer) customer = createCustomer(user._id); // magic synchronous call !