api.js   A
last analyzed

Complexity

Total Complexity 10
Complexity/F 1.25

Size

Lines of Code 52
Function Count 8

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 10%

Importance

Changes 0
Metric Value
cc 0
wmc 10
nc 1
mnd 1
bc 10
fnc 8
dl 0
loc 52
ccs 2
cts 20
cp 0.1
crap 0
rs 10
bpm 1.25
cpm 1.25
noi 2
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
B ➔ ??? 0 25 1
1
"use strict";
2
3 1
exports.getInformation = (postId) => {
4
    return fetch('http://localhost:3000/posts/' + postId)
5
        .then((response) => response.json())
6
        .then((responseJson) => {
7
            let jsonInfo = responseJson.json;
8
            let information;
9
10
            try {
11
                let info = {
12
                    title: jsonInfo.items[0].title,
13
                    link: jsonInfo.items[0].link
14
                };
15
16
                information = info;
17
            } catch (e) {
18
                console.error('\x1b[41m', 'Undefined map item', '\x1b[0m');
19
            }
20
            // console.log("outsude");
21
            // console.log(information);
22
            return information;
0 ignored issues
show
Bug introduced by
The variable information does not seem to be initialized in case let info = {IdentifierNo...ifierNode(link,false))} on line 11 throws an error. Are you sure this can never be the case?
Loading history...
23
        })
24
        .catch((error) => {
25
            console.error(error);
26
        });
27
};
28
29 1
exports.getUserInformation = (userId) => {
30
    return fetch('http://localhost:3000/users/' + userId)
31
        .then((response) => response.json())
32
        .then((responseJson) => {
33
            let jsonInfo = responseJson.json;
34
            let information;
35
36
            try {
37
                let info = {
38
                    name: jsonInfo.items[0].display_name,
39
                    link: jsonInfo.items[0].link
40
                };
41
42
                information = info;
43
            } catch (e) {
44
                console.error('\x1b[41m', 'Undefined map item', '\x1b[0m');
45
            }
46
47
            return information;
0 ignored issues
show
Bug introduced by
The variable information does not seem to be initialized in case let info = {IdentifierNo...ifierNode(link,false))} on line 37 throws an error. Are you sure this can never be the case?
Loading history...
48
        })
49
        .catch((error) => {
50
            console.error(error);
51
        });
52
};
53