Skip to content

Commit 5b949c8

Browse files
committed
JSON.parse error fix
1 parent 43f4723 commit 5b949c8

File tree

4 files changed

+79
-79
lines changed

4 files changed

+79
-79
lines changed

examples/getComUsers.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
console.log("Get a payload of message inside one one species chat room");
2-
const env = require('./env');
3-
const Amino = require('../index');
4-
(async function () {
5-
const sid = await Amino.login(env.email, env.password);
6-
const myCommunities = await Amino.getJoinedComs();
7-
const firstCommunity = myCommunities.coms[0];
8-
const users = await Amino.getComUsers(firstCommunity.id);
9-
console.log(users)
1+
console.log("Get a payload of message inside one one species chat room");
2+
const env = require('./env');
3+
const Amino = require('../index');
4+
(async function () {
5+
const sid = await Amino.login(env.email, env.password);
6+
const myCommunities = await Amino.getJoinedComs();
7+
const firstCommunity = myCommunities.coms[0];
8+
const users = await Amino.getComUsers(firstCommunity.id);
9+
console.log(users)
1010
})();

modules/getComUsers.js

+35-35
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
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;
3636
};
+21-21
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
if(process.env.TRAVIS_PULL_REQUEST === 'false' || typeof process.env.TRAVIS_PULL_REQUEST === 'undefined'){
2-
require('../helpers/loadEnv');
3-
describe('how the methods should response (With NO false input)', () => {
4-
it('Get the latest blog feed of one specie community', async () => {
5-
const Amino = require('../../index');
6-
const sid = await Amino.login(process.env.AMINO_EMAIL, process.env.AMINO_PASSWORD);
7-
const myCommunities = await Amino.getJoinedComs();
8-
const firstCommunity = myCommunities.coms[0];
9-
const myCommunityBlogFeed = await Amino.getComBlogFeed(firstCommunity.id);
10-
const comments = await Amino.getCommentsPost(firstCommunity.id, myCommunityBlogFeed.blogs[0].blogId);
11-
expect(comments.comments).toBeDefined();
12-
expect(
13-
Array.isArray(comments.comments)
14-
)
15-
.toBe(true);
16-
expect(comments.status).toBe('ok');
17-
expect(comments.error).toBeNull();
18-
});
19-
});
20-
}else{
21-
describe.skip();
1+
if(process.env.TRAVIS_PULL_REQUEST === 'false' || typeof process.env.TRAVIS_PULL_REQUEST === 'undefined'){
2+
require('../helpers/loadEnv');
3+
describe('how the methods should response (With NO false input)', () => {
4+
it('Get the latest blog feed of one specie community', async () => {
5+
const Amino = require('../../index');
6+
const sid = await Amino.login(process.env.AMINO_EMAIL, process.env.AMINO_PASSWORD);
7+
const myCommunities = await Amino.getJoinedComs();
8+
const firstCommunity = myCommunities.coms[0];
9+
const myCommunityBlogFeed = await Amino.getComBlogFeed(firstCommunity.id);
10+
const comments = await Amino.getCommentsPost(firstCommunity.id, myCommunityBlogFeed.blogs[0].blogId);
11+
expect(comments.comments).toBeDefined();
12+
expect(
13+
Array.isArray(comments.comments)
14+
)
15+
.toBe(true);
16+
expect(comments.status).toBe('ok');
17+
expect(comments.error).toBeNull();
18+
});
19+
});
20+
}else{
21+
describe.skip();
2222
}

test/modules/postBlog.test.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
if(process.env.TRAVIS_PULL_REQUEST === 'false' || typeof process.env.TRAVIS_PULL_REQUEST === 'undefined'){
2-
require('../helpers/loadEnv');
3-
describe('how the methods should response (With NO false input)', () => {
4-
it('should post a Blog into a given Community', async () => {
5-
const Amino = require('../../index');
6-
const sid = await Amino.login(process.env.AMINO_EMAIL, process.env.AMINO_PASSWORD);
7-
const blog = await Amino.postBlog(process.env.AMINO_DEBUG_COMMUNITY, `Debug Testcase ${process.env.TRAVIS_JOB_ID}`, `The Commitname was: ${process.env.TRAVIS_COMMIT} and the Message was: ${process.env.TRAVIS_COMMIT_MESSAGE}`);
8-
expect(blog.blog).toBeDefined();
9-
expect(blog.status).toBe('ok');
10-
expect(blog.error).toBeNull();
11-
});
12-
});
13-
}else{
14-
describe.skip();
1+
if(process.env.TRAVIS_PULL_REQUEST === 'false' || typeof process.env.TRAVIS_PULL_REQUEST === 'undefined'){
2+
require('../helpers/loadEnv');
3+
describe('how the methods should response (With NO false input)', () => {
4+
it('should post a Blog into a given Community', async () => {
5+
const Amino = require('../../index');
6+
const sid = await Amino.login(process.env.AMINO_EMAIL, process.env.AMINO_PASSWORD);
7+
const blog = await Amino.postBlog(process.env.AMINO_DEBUG_COMMUNITY, `Debug Testcase ${process.env.TRAVIS_JOB_ID}`, `The Commitname was: ${process.env.TRAVIS_COMMIT} and the Message was: ${process.env.TRAVIS_COMMIT_MESSAGE}`);
8+
expect(blog.blog).toBeDefined();
9+
expect(blog.status).toBe('ok');
10+
expect(blog.error).toBeNull();
11+
});
12+
});
13+
}else{
14+
describe.skip();
1515
}

0 commit comments

Comments
 (0)