-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathscript2.js
More file actions
30 lines (27 loc) · 719 Bytes
/
script2.js
File metadata and controls
30 lines (27 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Now a little bit more realistic:
// const fetch = require('node-fetch'); you no longer need this package if you have the latest version of Node!
const getPeoplePromise = (fetch) => {
return fetch('http://swapi.py4e.com/api/people')
.then(response => response.json())
.then(data => {
return {
count: data.count,
results: data.results
}
})
}
const getPeople = async (fetch) => {
const getRequest = await fetch('http://swapi.py4e.com/api/people');
const data = await getRequest.json();
// console.log(data);
return {
count: data.count,
results: data.results
};
}
// getPeople();
// getPeoplePromise();
module.exports = {
getPeople,
getPeoplePromise
}