Loop with delay in Postman test script

My API has two endpoints, one for starting a process and a second to check if that process has finished.

There can only be three states returned by the second endpoint: running, success or failure. Running is a temporary state, and once the process finishes, it will be marked as success or failure permanently.

How can I write a test script that keeps sending a request to the second endpoint (1 second delay) until it stops responding with running?

I’ve tried using pm.sendRequest but with no success. Since it is an async/callback function, it doesn’t work well when calling it recursively. I’ve also tried some setTimeout / setInterval hacks but with no success. And also, unfortunately, postman doesn’t support async / await syntax.