Synchronous call to a meteor method

So, say I have this simple meteor method

Meteor.methods checkInstagram: (token) -> true

(not sure how to indent, but this is a coffeescript)

On my AngularJS Controller, I couldn’t figure out how to run this synchronously.

@scopevar = -> myvar = 'false Meteor.call 'checkInstagram', 'test', (err, data) -> myvar = data console.log myvar
This returns false.

Any help is appreciated. Thanks!

if you’re using 1.3, I recommend installing bluebird. (meteor npm install --save bluebird).

Then, you can use async/await. Here’s an example.

import Promise from "bluebird";
import {Meteor} from "meteor/meteor";

const callAsync = Promise.promisify(Meteor.call);
// whatever here
async function doSomething() {
  const res = await callAsync("my function");
}

This code is embedded on the AngularJS controller?

– just to clarify i’m running angular-meteor.