Difficult to implement paging at Angular 2+

Asked

Viewed 54 times

0

You can see that back-end paging is working.

inserir a descrição da imagem aqui

My goal is to achieve returns the first three records of the first tab in Angular as shown in Postman, if I manage to complete this first step of implementation I will be able to do the rest.

That was my attempt;

Service class;

  getMenuPage(skip, limit): Observable<any>{
      return this._http.get(`${this.url}/menuspage?page=${skip}&size=${limit}`)
      .map(res => res.json());

    }

And that’s my component class;

  public title: string;
  public menu: Menu[];

  constructor(
    private _menuService: MenuAdminService
  ) {
      this.title = 'Lista de Cardápios';

    }

  ngOnInit() {
    this.getMenusPage(0,4);
  }

  getMenusPage(skip, limit) {
    this._menuService.getMenuPage(skip, limit).subscribe(
      response => {
       console.log(response.data)
        if (!response.data) {

        } else {
          this.menu = response.data;
        }
      },
      error => {
        console.log(<any>error);
      }
    );
  }

The return of my browser consoles is this:

Array(0)length: 0__proto__: Array(0)

How do I fix this implementation?

  • 2

    seems to have a typo in your url tries: ${this.url}/menuspage?skip=${skip}&limit=${limit}

  • That’s right @Eduardovargas, thank you very much

  • You can put your answer, thank you very much.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.