javascript - setTimeout in Winjs -


Regarding the server API, I should limit 3 seconds per requests. Here is my code:

  groups.forEach (work (group) {Api.simpleRequest (uri). Then (function (res) {// processing result}, function (error) {/ / error handling }); });   

What I tried to do: 1.

 for  (var i = 0; i & lt; groups.length; i ++) {(Function (index) {SetTimeout (function () {Api.simpleRequest (url). Then () // ...}, 1000);}) (i); }; Trying to use   
  1. WinJS.Promise.timeout (1000) , then continue my promise.

    Both options do not work for me.

    Just got the solution to work, but < setTimeout ()

      var i = 0; Instead of strong> setInterval ()  Var length = groups. Long - 1; Var timer = setInterval (function () {Api.simpleRequest (uri) .then () // ... if (i == groups.length) {clearInterval (timer);}} i ++;});    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -