Closed jay11ca39 closed 5 years ago
No. You cannot write synchronous function with promises. But you can use an "await/async" chain.
Like @triadium said, you cannot do this. The requests are based on node.js’s core libraries which are async by design. But indeed, await / async are your friends. Or generators (function *
) and yield
for older versions of node.js.
I want to write a synchronous function, which return the rest response which it receive from server. For example:
The above function should exit only when it receive response from the server.... I am not sure about the working of request-promise will it provide this feature or there is any other way to do this ?