-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.js
49 lines (49 loc) · 1.48 KB
/
init.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
var app = new Vue({
el: '#app',
data: {
id: 'd241683d5d4180884182',
secret: '68a1c57c8be8fc7774b5abb546caa9835b39b957',
username: 'kamilrogala',
userData: {},
userRepositories: []
},
methods: {
findUser: function (username) {
this.getUserData(username);
this.getUserRepositories(username);
},
getUserData: function (username) {
fetch('https://api.github.com/users/' + username + '?client_id=' + this.id + '&client_secret=' + this.secret)
.then(resp => resp.json())
.then(resp => {
this.userData.name = resp.name;
this.userData.avatar_url = resp.avatar_url;
this.userData.html_url = resp.html_url;
this.userData.public_repos = resp.public_repos;
this.userData.public_gists = resp.public_gists;
this.userData.followers = resp.followers;
this.userData.following = resp.following;
this.userData.company = resp.company;
this.userData.blog = resp.blog;
this.userData.blog = resp.blog;
this.userData.location = resp.location;
this.userData.created_at = resp.created_at;
});
},
getUserRepositories: function (username) {
fetch('https://api.github.com/users/' + username + '/repos?client_id=' + this.id + '&client_secret=' + this.secret + '&sort=created:asc&per_page=5')
.then(resp => resp.json())
.then(resp => {
this.userRepositories = resp;
});
}
},
created: function () {
this.findUser(this.username);
},
watch: {
username: function (username) {
this.findUser(username)
}
}
});