Trying to wrapAsync with Restivus


#1

Hi, i am building a mobile app with Meteor, i’m trying to use restivus to call an async API but I feel kind stupid… Anyone done this and can you provide an example please?


#2

Answering my own question, just figured it out

Api.addRoute 'products', authRequired: false,
  get: ->
    getProducts = ->
      fut = new Future
      Meteor.http.get 'https://api.instagram.com/v1/tags/shoes/media/recent?access_token=22871033.a14a64', (error, result) ->
        if error
          return console.log(error)
        console.log fut
        fut.return result
        return
      fut.wait()

    status: 'success', data: getProducts()