Polling
Asking an API 'anything new?' on a timer instead of waiting to be told. Simple, a bit wasteful, and often the right call.
See it
What it is
Polling is a loop: call the endpoint, look at the answer, wait, call again. It is the opposite of a webhook, where the other service calls you. Reach for it when the provider has no push option, when you cannot expose a public URL (local dev, a laptop behind a firewall), or when you are just waiting out a job that finishes in seconds anyway.
Two upgrades before you reach for sockets. Long polling holds the request open until data arrives or the server gives up, which cuts latency without new infrastructure. Conditional requests (send back the ETag or If-Modified-Since and get a 304 with no body) cut the bandwidth and serialization cost of an unchanged poll to almost nothing. You still pay for the request itself, and the server still has to work out whether anything changed, so cheaper is the claim, not free. A cursor or 'updated_since' parameter beats refetching the whole list every tick.
Gotchas: a fixed setInterval stacks up requests once responses get slower than the interval, so schedule the next poll after the previous one settles. Poll rate multiplies by user count and eats rate limits fast, so slow down when nothing is changing, add a little random jitter, and stop entirely when the tab is hidden or the component unmounts.
Ask AI for it
Write a polling loop that checks this endpoint until the job reaches a terminal state. Start at a 2 second interval, schedule the next request only after the previous response settles (never a bare setInterval), add random jitter, slow the interval down while nothing changes, and give up after a hard deadline with a clear error. Send conditional request headers so unchanged responses come back as 304, cancel the in-flight request with an AbortController on unmount, and pause polling while document.visibilityState is 'hidden'.