1

I would like to get a varible from inside .then function. I cannot return the variable called d.isOnline to where it is called.Can you help me ? Thanks.

function find_online(id){
            Store.Presence.find(id).then(function(d){
                if (d.isOnline)
                    return d.isOnline;
                else
                    return d.isOnline;
            });
        }

var id = '1234';
var isOnline = find_online(id);  //I CANNOT GET IT HERE
Berat
  • 9
  • 1
  • 1
    Please see [How do I return the response from an aynchronous call](https://stackoverflow.com/q/14220321/438992), which this duplicates. – Dave Newton Nov 24 '18 at 20:37
  • In this case all you need to do is `return` the value of `Store.presence.find()` and then put the code that needs the return value in another `then()` callback. – Pointy Nov 24 '18 at 20:38
  • Might as well return a Promise and fetch data in a `then()` callback. – Thielicious Nov 24 '18 at 21:53

0 Answers0