-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
70 lines (61 loc) · 2.19 KB
/
test.js
File metadata and controls
70 lines (61 loc) · 2.19 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
var request = require('request');
const assemble = require('./utils/assemble')
const compile = require('./utils/compile');
const toView = require('./utils/toView')
const util = require('util')
const filterMods = require('./utils/filterMods')
/*
var options = {
'method': 'PUT',
'url': 'http://modtree-api.netlify.app/.netlify/functions/user/account',
'headers': {
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVmMDEzYjBhMzlkMjIzMDAwNzFmYmM0YSIsIm5hbWUiOiJuZXdOYW1lIiwiZW1haWwiOiJ0ZXN0QHRlc3QuY29tIiwiaWF0IjoxNTk0ODY4OTIyLCJleHAiOjE2MjY0MjU4NDh9.YbLYPqotgU6oaof0DJlu0w_M0DLpXPmr9Uo63T2KENI',
'Content-Type': 'application/x-www-form-urlencoded'
},
form: {
'name': 'Testy McTestFace',
'minors': [{'tag': 'minor_management'}]
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
*/
/*
assemble('r_ba_degree')
.then(compile)
.then(func => func({modules: ['CS1101S']}))
.then(console.log)
*/
var request = require('request');
var options = {
'method': 'GET',
'url': 'http://modtree-api.netlify.app/.netlify/functions/rules/assemble/r_acc_degree',
'headers': {
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVmMDEzYjBhMzlkMjIzMDAwNzFmYmM0YSIsIm5hbWUiOiJuZXdOYW1lIiwiZW1haWwiOiJ0ZXN0QHRlc3QuY29tIiwiaWF0IjoxNTk0ODY4OTIyLCJleHAiOjE2MjY0MjU4NDh9.YbLYPqotgU6oaof0DJlu0w_M0DLpXPmr9Uo63T2KENI',
'Content-Type': 'application/x-www-form-urlencoded'
},
form: {
'name': 'Testy McTestFace',
'minors': [{'tag': 'minor_management'}]
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
const obj = JSON.parse(response.body);
compile(obj)
.then(func => func({modules: ['CS1101S']}))
.then(toView)
//.then(obj => console.log(obj.sub[0]))
//console.log(obj.params.list[0].params.list)
.then(myObject => console.log(util.inspect(myObject, {showHidden: false, depth: null})));
//console.log(asdf);
});
/*
assemble('r_ceg_degree')
.then(compile)
.then(func => func({modules: ['CS4236', 'CS4238', 'DBA4811', 'FSP4003']}))
//.then(toView)
.then(myObject => console.log(util.inspect(myObject, {showHidden: false, depth: null})));
*/