Call a callback appropriately from a promise