How to run wp_remote_get() inside of a loop for multiple page API response?

If I’m reading the docs right, wp_remote_get() will return a WP_Error on failure, but not necessarily on a 404/400/403 (etc) status code from your remote server. (Though that will depend in part on what your remote server sends back if there’s an invalid request.)

You can check the status code using wp_remote_retrieve_response_code().

I’d use something like this:

$page = 1;
$results = array();
$url="https://example.com/products&page=" . $page;
$keep_going = true;
while ( $keep_going ) {
    $request = wp_remote_get( $url, $args ); // This assumes you've set $args previously
    if ( is_wp_error( $request ) ) {
        // Error out.
        $keep_going = false;
    }
    if ( $keep_going ) {
        $status = wp_remote_retrieve_response_code();
        if ( 200 != $status ) {
            // Not a valid response.
            $keep_going = false;
        }
    }
    if ( $keep_going ) {
        $data = wp_remote_retrieve_body($request);
        $body = json_decode($data);

        foreach ($data as $datapoint) {
            array_push($results, $datapoint);
        }

        ++ $page;
        // URL for the next pass through the while() loop
        $url="https://example.com/products&page=" . $page;
    }
}

This code is untested and probably inelegant, but it should provide a decent starting point for you. If you’re unclear on while() loops, check the PHP docs.