-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (27 loc) · 830 Bytes
/
index.js
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
31
32
33
34
35
36
var app = require('express')();
var http = require('http').Server(app);
var request = require('request');
var options = {
method: 'GET',
json: {},
uri: 'https://api.clever.com/v1.1/sections',
headers: {
Authorization: 'Bearer DEMO_TOKEN'
}
};
request(options, function(err, response, body) {
var sections = body.data;
var students = sections.map(function(section) {
return section.data.students.length;
});
var allStudents = students.reduce(function(a, b) {
return a + b;
})
console.log("TOTAL NUMBER OF SECTIONS", students.length);
console.log("ALL STUDENTS", allStudents);
var averageNumberOfStudentsPerSection = allStudents/students.length;
console.log("AVERAGE", averageNumberOfStudentsPerSection);
});
http.listen(3000, function(){
console.log('listening on *:3000');
});