Mostly done now, search works.
This commit is contained in:
parent
51b18823ae
commit
c29077aa4c
4 changed files with 72 additions and 12 deletions
|
@ -4,17 +4,28 @@ class PaginateTable {
|
|||
this.items = [];
|
||||
this.url = url;
|
||||
this.headers = [];
|
||||
this.search_query=""
|
||||
}
|
||||
|
||||
async contents() {
|
||||
if(this.page < 0) this.page = 0;
|
||||
|
||||
const resp = await fetch(`${this.url}?page=${this.page}`);
|
||||
let url = `${this.url}?page=${this.page}`;
|
||||
|
||||
if(this.search_query !== "") {
|
||||
this.page = 0;
|
||||
url += `&search=${this.search_query}`
|
||||
}
|
||||
|
||||
const resp = await fetch(url);
|
||||
console.assert(resp.status == 200, "failed to get it");
|
||||
|
||||
this.items = await resp.json();
|
||||
const items = await resp.json();
|
||||
|
||||
this.headers = Object.keys(this.items[0]);
|
||||
if(items) {
|
||||
this.items = items;
|
||||
this.headers = Object.keys(this.items[0]);
|
||||
}
|
||||
|
||||
return this.items;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue