How to block on asynchronous functions in JavaScript

前端 未结 5 1757
臣服心动
臣服心动 2020-12-09 12:20

I need to write a function in JavaScript, which returns a state from calling an asynchronous function. However, the caller only receives the value and no callback function i

5条回答
  •  萌比男神i
    2020-12-09 12:54

    The best would be to put the logic you want to have called into the callback function. Is there any reason why you can't do that?

    You could use setInterval to check on the result, but that requires a callback function, too...

提交回复
热议问题