Javascrpit API

update API response

I use an API call on my application page to return the tasks of a process, for example: Process 01 with the Tasks (Step1, Step2, Step3).

I need to create a javascript code that recognizes when a change from Step1 to Step 2 occurs. That is, when one task completes and moves on to the next. The problem is, the API always returns the outdated value from my task list. When a task is executed, the return of my API does not change automatically, I need something that does this.