From e5bcb8b2094497b14f1c53b214098e316999b7a7 Mon Sep 17 00:00:00 2001 From: Wilfred Asomani Date: Wed, 2 Aug 2023 21:46:54 +0000 Subject: [PATCH] web/satellite: use get user projects http endpoint This change uses the new /projects endpoint in place of the GraphQL MyProjects query. Issue: https://github.com/storj/storj/issues/6132 Change-Id: Ie4ae69dd6def75c4b8c627aaf55c31914cf69ce5 --- web/satellite/src/api/projects.ts | 40 ++++++++++++++----------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/web/satellite/src/api/projects.ts b/web/satellite/src/api/projects.ts index ba97adf10..614947038 100644 --- a/web/satellite/src/api/projects.ts +++ b/web/satellite/src/api/projects.ts @@ -56,30 +56,26 @@ export class ProjectsApiGql extends BaseGql implements ProjectsApi { * @throws Error */ public async get(): Promise { - const query = `query { - myProjects{ - name - publicId - description - createdAt - memberCount - ownerId - } - }`; + const response = await this.http.get(this.ROOT_PATH); - const response = await this.query(query); + if (!response.ok) { + throw new APIError({ + status: response.status, + message: 'Can not get projects', + requestID: response.headers.get('x-request-id'), + }); + } - return response.data.myProjects.map((project: Project & {publicId: string}) => { - return new Project( - project.publicId, - project.name, - project.description, - project.createdAt, - project.ownerId, - false, - project.memberCount, - ); - }); + const projects = await response.json(); + return projects.map((p: Project) => new Project( + p.id, + p.name, + p.description, + p.createdAt, + p.ownerId, + p.isSelected, + p.memberCount, + )); } /**