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
![]() |
|||
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
|
|||
48 | }) |
||
49 | .catch((error) => { |
||
50 | console.error(error); |
||
51 | }); |
||
52 | }; |
||
53 |