Get Drafts via $api

Hi.
The API /api/pages/:id/children return only listed and unlisted pages.
How tho get the drafts in panel?

this.$api.get("pages/my-page/children").then((a) => {
     console.log(a)
})

You can pass a status query.

From route test:

  // published
        $response = $app->api()->call('pages/parent/children', 'GET', [
            'query' => ['status' => 'published']
        ]);

I see…
In my case, the code looks like this:

this.$api.get("pages/my-page/children", { 'status': 'drafts' }).then((a) => {
     console.log(a)
})

But what if a draft-page is in between? Like…

this.$api.get("pages/listet-page+draft-page/children", { 'status': 'drafts' }).then((a) => {
     console.log(a)
})

Hm, theoretically, this should work. If not, you probably need a custom endpoint.

If someone struggeling with that too. here’s my solution:

The API:

'api' => [
  'routes' => [
    [
      'pattern' => 'form/get-requests',
      'action'  => function () {
        $parent = $this->kirby()->page($this->requestQuery('parent'));
        $child = $parent->drafts()->find($this->requestQuery('child'));
        return $child->drafts()->toArray(function($a) {
          return $a->content()->toArray();
        });
      }
    ]
  ]
]

The Request from Vue:

const url = "form/get-requests"
const params = {
  'parent': this.$attrs.endpoints.model.replace('/pages/', ''),
  'child': 'my-child'
}

this.$api.get(url, params).then((a) => {
  console.log(a)
})

If someone knows a more elegant solution - go ahead… :wink: