How to run two functions asynchronously in setInterval?

I have these two functions that take one argument each and which runs after every 2 seconds on a web page.

setInterval(() => {
}, 2000);

which is what I wanted and it works fine this way. But think it would be better if I could run these two functions asynchronously instead of this synchronous behavior. I am not very familiar with javascript asynchronous concepts. So can someone provide a basic solution to this with a bit explanation?

1 answer

  • answered 2018-11-08 06:19 Andreas

    You could use the async function when you declared those 2 function

    async function requestCall_1(api1) {
        // your code
    async function requestCall_2(api2) {
        // your code