Sometimes, when server is performing huge tasks, after we send a http request, it takes a huge time to load response.
Polling is a way, in which the process is assigned a unique id, and an api keeps checking for the process to complete using that unique id.
But the problem with using middlewares is I’ve to pass $next to dispatch() funciton and since next is of type Clouse and Closures can’t be serialized, I couldn’t use this technique.
To poll any api, we have to wrap the processing in a Job class, and we have to pass the job and processing to ProcessApiPoll::addToPoll(JobClass::class, $param1, $param2 …
And it will save the json_encoded form of response to the ApiPoll database we have created before, which will be accessed through the api we are going to create.