Virtual pages with JSON array

Hi

Me again :face_with_peeking_eye: with my API, I’m trying now to create virtual pages, and I have followed the guide from virtual pages with review.php, reviews.php template and this is my reviews.php model :

class ReviewsPage extends Page
{
    public function children()
    {
        if ($this->children instanceof Pages) {
            return $this->children;
        }

        $results = [];
        $pages   = [];
        $request = Remote::get('https://api.urlapi.fr/36/artworks/');

      
        if ($request->code() === 200) {
            $results = $request->json();
        }
       
        foreach ($results["results"] as $key => $review) {
            $pages[] = [
                'slug'     => Str::slug($review["_source"]["ua"]["artwork"]["authors_notice"]),
                'num'      => $key+1,
                'template' => 'review',
                'model'    => 'review',
                'content'  => [
                    'title'    => $review["_source"]["ua"]["artwork"]["authors_notice"],
                    'uuid'     => Uuid::generate(),

                ]
            ];
        }

        return $this->children = Pages::factory($pages, $this);
    }
}

But when I’m on my reviews.php template, I don’t get any children with

<?php foreach ($page->children() as $review): ?>
    <li>
      <h2><?= $review->title() ?></h2>
      <a href="<?= $review->url() ?>">Read review summary</a>
    </li>
    <?php endforeach ?>

I’m working with a JSON array here, but I don’t know how to check if the response is correct or not and where to find the childrens from the array I’m calling ?

Do you get an error or just nothing?

I tested your code and works for me, but did you import the Uuid class at the top of the model?

Nothing, I don’t get a list of childrens with titles.

And yes at the top of the model, I have :

<?php

use Kirby\Uuid\Uuid;

class ReviewsPage extends Page
{
...

Do you mean you get a list of childrens from your side ?

Yes, this is the result from your code above:

Thanks for your help and your test from your side, I’ve noticed I didn’t create multiple .txt files for each of my languages. Now I can see the list !

Thank you