-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
46 lines (40 loc) · 1.34 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<title>RESTful api client</title>
<script src="vendor/jquery-2.1.3.js"></script>
</head>
<body>
<script type="module">
import { ApiClient } from './dist/api-client.development.js';
var github = ApiClient('https://api.github.com', {
hooks: {
headers: {
Accept: 'application/vnd.github.v3+json',
Authorization: 'token e31ba2b2c80dfec76606d3a636e722fe4db0e64c',
},
},
unauthorizedCallback: function() {
}, // Вызывается всякий раз, когда код ответа от сервера 401
});
//github.read(); // GET https://api.github.com
github.add('user'); // /user
github.add('users'); // /users
github.users.add('repos'); // /users/repos
github.user.read(); // GET /user
github.users('archangel-irk').repos.read(); // GET /users/archangel-irk/repos
github.users('archangel-irk').repos.read({ sort: 'pushed' }); // GET /users/archangel-irk/repos?sort=pushed
var api = new ApiClient('http://0.0.0.0:3000');
api.add('users');
api.users.post({
username: 'login',
password: 'password',
}).done(function() {
console.log(arguments);
});
api.users.get().done(function() {
console.log(arguments);
});
</script>
</body>
</html>