Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination meta is undefined #339

Open
niskah-energies opened this issue Nov 27, 2021 · 0 comments
Open

Pagination meta is undefined #339

niskah-energies opened this issue Nov 27, 2021 · 0 comments

Comments

@niskah-energies
Copy link

niskah-energies commented Nov 27, 2021

Hi,

Sometimes when I'm trying to use server pagination, it appears that meta.page object if undefined.

this.request = this.usersService.all({
      page: { number: pageIndex, size: pageSize },
      remotefilter: filter,
      sort: sortBy
    })
      .subscribe((resp : DocumentCollection<User>) => {
        console.debug('resp', resp);  <-- resp.meta.page.total is defined
        console.debug('meta', resp.meta); <- defined but empty
        console.debug('page', resp.meta.page);  <- is undefined
        console.debug('total', resp.meta.page.total);  <- is undefined
        this.users = resp;
        this.total = resp.meta.page.total;
        this.pageSize = resp.meta.page.per_page;
        this.pageIndex = resp.meta.page.current_page;
        this.loading = false;
      },
        error => console.error('Could not load users :(', error)
      );

server response:

{
    "meta": {
        "page": {
            "current_page": 1,
            "from": 1,
            "last_page": 1,
            "per_page": 10,
            "to": 4,
            "total": 4
        }
    },
    "jsonapi": {
        "version": "1.0"
    },
    "links": {
        "first": "http://127.0.0.1:8000/api/v1/users?page%5Bnumber%5D=1&page%5Bsize%5D=10",
        "last": "http://127.0.0.1:8000/api/v1/users?page%5Bnumber%5D=1&page%5Bsize%5D=10"
    },
    "data": [
        {
            "type": "users",
            "id": "1",
            "attributes": {
                "email": "...",
                "name": "...",
                "token": "...",
                "created_at": "2020-05-05T15:22:21.000000Z",
                "updated_at": "2021-11-26T14:45:55.000000Z",
                "deleted_at": null
            },
            "relationships": {
                "customer": {
                    "links": {
                        "related": "http://127.0.0.1:8000/api/v1/users/1/customer",
                        "self": "http://127.0.0.1:8000/api/v1/users/1/relationships/customer"
                    }
                }
            },
            "links": {
                "self": "http://127.0.0.1:8000/api/v1/users/1"
            }
        },
        ...
    ]
}

console output:

[Debug] resp (src-app-pages-users-users-module.js, line 323)
DocumentCollection

builded: true

cache_last_update: 1638029003362

content: "collection"

data: [User, User, User, User] (4)

is_loading: false

loaded: true

meta: Object

page: {current_page: 1, from: 1, last_page: 1, per_page: 10, to: 4, …}

Prototype Object

page: Page {number: Object, total_resources: null, size: null, resources_per_page: null}

source: "server"

ttl: undefined

Prototype DocumentCollection
[Debug] meta (src-app-pages-users-users-module.js, line 324)
Object
Aucune propriété

Prototype Object
[Debug] page – undefined (src-app-pages-users-users-module.js, line 325)
[Debug] total – undefined (src-app-pages-users-users-module.js, line 326)

Any idea ??

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant