You think you will get a different response if you ask more than once?
Assuming there are no http errors then the data is the data, It would be an extremely poor API implementation if you got a better result if you ask again immediately.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
excuse me, im a junior dev, still struggle learn a lot about laravel. i want to ask how can i retry the http post based on condition? example i want to retry if the response->id != 1; $response = Http::retry(3, 100, function () { //if else condition })->get('https://fakestoreapi.com/products/1');
thanks.
@rizdhanhr This is how it works.
use Illuminate\Support\Facades\Http;
$response = Http::retry(3, 100, function ($response, $attempts) {
// This condition will be checked after each failed attempt to see if we should retry again.
// If the condition returns 'true', then the request will be retried.
return $response->json()['id'] != 1;
})->get('https://fakestoreapi.com/products/1');
// Handle the $response as needed.
Please or to participate in this conversation.