-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
90 lines (68 loc) · 1.83 KB
/
test.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
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
require('babel-core/register');
require('babel-polyfill');
const Dianoia = require('./dist');
const api = new Dianoia.Dianoia({
baseURL: 'http://localhost:1337'
});
const email = 'Barth';
const password = 'barth';
async function login() {
return await api.loginUser(email, password);
}
async function me() {
return await api.getUser();
}
async function register() {
return await api.registerUser('[email protected]', 'bratcher', 'kelsey', 'bratcher');
}
async function updateUser(user_id) {
return await api.updateUser(user_id, {
first_name: 'Kels'
});
}
async function addClass(user, class_id) {
return await api.addClassToUser(user, class_id);
}
async function getAllClasses() {
return await api.getAllClasses();
}
async function getAllCards() {
return await api.getAllCards();
}
async function getAllNotes() {
return await api.getAllNotes();
}
async function createNote() {
return await api.addUserNote(
"This is a note from the dianoia-js library",
"5b0c187c1fcd9f3793c8413e"
);
}
async function updateNote() {
return await api.updateUserCardNote({
note_id: "5b281600d7f56e82539bca61",
card_score: 27
});
}
async function test() {
const response = await login();
api.setJWT(response.jwt);
// const user = await me();
// console.log(user);
// const note = await getAllNotes();
const note = await updateNote();
console.log(note);
// const res2 = await addClass(user,"5af0e1eb9bd37604420c2156");
// console.log(res2);
// const response = await register();
// console.log(response);
}
test();
// try {
// const user = api.loginUser(email, password);
// user.then(res => console.log(res));
// // console.log(user);
// }
// catch(err) {
// console.error(err);
// }