Firing properly but no data returned on extended fetch

This commit is contained in:
Matthew Raymer
2023-06-24 17:47:18 +08:00
parent 0726a8d3ba
commit 071c41b70c
2 changed files with 46 additions and 16 deletions

View File

@@ -118,15 +118,29 @@ import InfiniteScroll from "@/components/InfiniteScroll";
export default class ProjectsView extends Vue {
apiServer = "";
projects: { handleId: string; name: string; description: string }[] = [];
current: IIdentifier;
isDataLoaded = false;
async loadMoreData(payload: boolean) {
console.log("loadMoreData");
console.log(payload);
if (this.projects.length > 0) {
const afterId = this.projects[this.projects.length - 1]["handleId"];
console.log(this.projects[this.projects.length - 1]);
const afterurl = this.projects[this.projects.length - 1]["handleId"];
const regex = /([0-9A-Z]+)$/; // Regular expression to match one or more digits at the end
const matches = afterurl.match(regex);
let afterId = "";
if (matches && matches.length > 1) {
afterId = matches[1];
console.log(afterId); // Output: 01H3HBVZGH3YE0K27X35S15QT1
} else {
console.log("No digits found at the end of the URL.");
return;
}
const url =
this.apiServer + "/api/v2/report/plansByIssuer?afterId=" + afterId;
const token = await accessToken(identity);
const token = await accessToken(this.current);
const headers = {
"Content-Type": "application/json",
Authorization: "Bearer " + token,
@@ -163,6 +177,7 @@ export default class ProjectsView extends Vue {
}
async LoadProjects(identity: IIdentifier) {
console.log("LoadProjects");
const url = this.apiServer + "/api/v2/report/plansByIssuer";
const token = await accessToken(identity);
const headers = {
@@ -185,6 +200,8 @@ export default class ProjectsView extends Vue {
};
this.projects.push(data);
}
this.isDataLoaded = true;
}
} catch (error) {
console.error("Got error loading projects: ", error);
@@ -206,6 +223,7 @@ export default class ProjectsView extends Vue {
const accounts = await accountsDB.accounts.toArray();
const account = R.find((acc) => acc.did === activeDid, accounts);
const identity = JSON.parse(account?.identity || "undefined");
this.current = identity;
this.LoadProjects(identity);
}
}