Skip to content

Commit d7e4a5b

Browse files
author
Dushyant Bhalgami
committed
updated getGroups function
1 parent e3b5d0c commit d7e4a5b

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/services/groups.js

+15-11
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ function mergeGroup(groups, group) {
174174
* @param {Object} group
175175
* @return {String[]} Array of IDs.
176176
*/
177-
export function reduceGroupIds({ id, subGroups }) {
178-
let res = [id];
177+
export function reduceGroupIds({ oldId, subGroups }) {
178+
let res = [oldId];
179179
if (subGroups) {
180180
subGroups.forEach((g) => {
181181
res = res.concat(reduceGroupIds(g));
@@ -212,10 +212,12 @@ class GroupService {
212212
* @param {String} membershipType
213213
* @return {Promise}
214214
*/
215-
addMember(groupId, memberId, membershipType) {
216-
return this.private.api.postJson(`/groups/${groupId}/members`, {
215+
async addMember(groupId, memberId, membershipType) {
216+
const response = await this.private.api.postJson(`/groups/${groupId}/members`, {
217217
param: { memberId, membershipType },
218-
}).then(handleApiResponse);
218+
});
219+
220+
return handleApiResponse(response);
219221
}
220222

221223
/**
@@ -230,12 +232,14 @@ class GroupService {
230232
* whether the response should information about sub-groups, if any.
231233
* @return {Promise} On success resolves to the group data object.
232234
*/
233-
getGroup(groupId, withSubGroups = true) {
235+
async getGroup(groupId, withSubGroups = true) {
234236
let url = `/groups/${groupId}`;
235237
if (withSubGroups) {
236-
url = `${url}/getSubGroups?includeSubGroups=true&oneLevel=false`;
238+
url = `${url}/?includeSubGroups=true&oneLevel=false`;
237239
}
238-
return this.private.api.get(url).then(handleApiResponse);
240+
241+
const response = await this.private.api.get(url)
242+
return handleApiResponse(response);
239243
}
240244

241245
/**
@@ -325,9 +329,9 @@ class GroupService {
325329
* @return {Promise} On sucess resolves to the array of member objects,
326330
* which include user IDs, membership time, and some bookkeeping data.
327331
*/
328-
getMembers(groupId) {
329-
return this.private.api.get(`/groups/${groupId}/members`)
330-
.then(handleApiResponse);
332+
async getMembers(groupId) {
333+
const response = await this.private.api.get(`/groups/${groupId}/members`);
334+
return handleApiResponse(response);
331335
}
332336

333337
/**

0 commit comments

Comments
 (0)