1
- const fetch = require ( 'isomorphic-fetch' ) ;
2
- const endpoints = require ( '../helpers/endpoints.js' ) ; //For Creating shorter URL's in this Module
3
- const objs = require ( '../helpers/objects.js' ) ; //For Storing the Objects that the Framework returns.
4
- const { getConfig, errorMessages } = require ( '../index' ) ;
5
-
6
- /**
7
- * Gets a JSON-Object were all Community ID's, Name's and URL's for the current Logged-In Account are obainted in.
8
- * @param {SecurityString } sid For authenticating with the Narvii-API.
9
- * @returns {Object } Object containing all Joined Coms with the Logged in Account.
10
- */
11
-
12
- module . exports = async function getComUsers ( communityId ) {
13
- let communityUsers = objs . communityUsers ;
14
- communityUsers . users = [ ] ;
15
- const sid = getConfig ( 'sid' ) ;
16
- if ( typeof sid != 'string' ) {
17
- throw new Error ( errorMessages . missingSid ) ;
18
- }
19
- try {
20
- const response = await fetch ( endpoints . getComUsers ( communityId ) , {
21
- headers : {
22
- 'NDCAUTH' : `sid=${ sid } `
23
- }
24
- } ) ;
25
- const body = await response . json ( ) ;
26
- communityUsers . users = body . userProfileList ;
27
- communityUsers . count = body . userProfileCount ;
28
- communityUsers . error = null ;
29
- communityUsers . status = 'ok' ;
30
- }
31
- catch ( err ) {
32
- communityUsers . error = err ;
33
- throw 'Error while calling getComUsers: ' + err ;
34
- }
35
- return communityUsers ;
1
+ const fetch = require ( 'isomorphic-fetch' ) ;
2
+ const endpoints = require ( '../helpers/endpoints.js' ) ; //For Creating shorter URL's in this Module
3
+ const objs = require ( '../helpers/objects.js' ) ; //For Storing the Objects that the Framework returns.
4
+ const { getConfig, errorMessages } = require ( '../index' ) ;
5
+
6
+ /**
7
+ * Gets a JSON-Object were all Community ID's, Name's and URL's for the current Logged-In Account are obainted in.
8
+ * @param {SecurityString } sid For authenticating with the Narvii-API.
9
+ * @returns {Object } Object containing all Joined Coms with the Logged in Account.
10
+ */
11
+
12
+ module . exports = async function getComUsers ( communityId ) {
13
+ let communityUsers = objs . communityUsers ;
14
+ communityUsers . users = [ ] ;
15
+ const sid = getConfig ( 'sid' ) ;
16
+ if ( typeof sid != 'string' ) {
17
+ throw new Error ( errorMessages . missingSid ) ;
18
+ }
19
+ try {
20
+ const response = await fetch ( endpoints . getComUsers ( communityId ) , {
21
+ headers : {
22
+ 'NDCAUTH' : `sid=${ sid } `
23
+ }
24
+ } ) ;
25
+ const body = await response . json ( ) ;
26
+ communityUsers . users = body . userProfileList ;
27
+ communityUsers . count = body . userProfileCount ;
28
+ communityUsers . error = null ;
29
+ communityUsers . status = 'ok' ;
30
+ }
31
+ catch ( err ) {
32
+ communityUsers . error = err ;
33
+ throw 'Error while calling getComUsers: ' + err ;
34
+ }
35
+ return communityUsers ;
36
36
} ;
0 commit comments