R
R
Rostislav2018-04-04 19:25:06
Node.js
Rostislav, 2018-04-04 19:25:06

How to make the function wait for the Promise result from the server and only then return the value?

Let's say there is code like this.

data.getData({
        param: param
    }).then((result) => {
        log( result)
    }).catch(err => {
        log(err)
    })

Is there any way to wrap this code in a function without building blocks with then() to get a fresh result and immediately return it in this function?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question