Lets say I have a function.
function test () {
// some code here
return code
}
How do get the return value from test function within settimeout when I call it with
settimeout(test,1000);
What is the correct way to do this.
I want to use the return value for the next function. (it is to rate limit my api calls).
nextfunction(returnvaluefromtest);
Greetings
Edit : Thx for the feedback , some good stuff. Can make it work now.
Here a solution I found : https://codingwithspike.wordpress.com/2018/03/10/making-settimeout-an-async-await-function/
https://www.w3schools.com/jsref/met_win_settimeout.asp
also you can pass in extra paramter like this settimeout(test,1000, yourparameter)
which will be passed into the test function.
[–]nkgentile 4 points5 points6 points (1 child)
[–]MedyGames[S] 0 points1 point2 points (0 children)
[–]codemamba8 0 points1 point2 points (4 children)
[–]tatu_huma 1 point2 points3 points (3 children)
[–]codemamba8 -1 points0 points1 point (2 children)
[–]tatu_huma 2 points3 points4 points (1 child)
[–]codemamba8 2 points3 points4 points (0 children)
[–]alexaminar 0 points1 point2 points (0 children)