0

I want to create function that get value from Promise.prototype.then(), but I don't exactly know how it's works.

I have such code:

ConfigurationPage.filteredItems.getText().then(function(value){console.log(value)});

and in console log I get some value - it's OK.

I try to create function that looks like this:

function getValue(data) {
return data.then(function(value){value})}

My expected result when I call such function:

getValue(ConfigurationPage.filteredItems.getText())

I get a value.

But I don't know how to create right function.

Thanks for support.

  • 2
    Do you understand well the difference between asynchronous and synchronous code? Well, this is it - you can't really do it the way you would expect. I'm closing it as duplicate, check the duplicate question it will explain everything in details. – dfsq May 07 '16 at 09:18
  • Normally in such cases I merely climb into my time machine and visit the future to find the value. –  May 07 '16 at 10:04
  • :-) Ok, guys. I understood my mistake. Thanks for help. – Alexander Melnychuk May 09 '16 at 07:30

0 Answers0