@@ -6,15 +6,15 @@ const app = new Vue({
6
6
} ,
7
7
methods : {
8
8
deleteFriend ( id , i ) {
9
- fetch ( "http://rest.learncode.academy/api/vue-5/friends /" + id , {
9
+ fetch ( "http://localhost:3000/v1/characters /" + id , {
10
10
method : "DELETE"
11
11
} )
12
12
. then ( ( ) => {
13
13
this . friends . splice ( i , 1 ) ;
14
14
} )
15
15
} ,
16
16
updateFriend ( friend ) {
17
- fetch ( "http://rest.learncode.academy/api/vue-5/friends /" + friend . id , {
17
+ fetch ( "http://localhost:3000/v1/characters /" + friend . id , {
18
18
body : JSON . stringify ( friend ) ,
19
19
method : "PUT" ,
20
20
headers : {
@@ -27,25 +27,27 @@ const app = new Vue({
27
27
}
28
28
} ,
29
29
mounted ( ) {
30
- fetch ( "http://rest.learncode.academy/api/vue-5/friends " )
30
+ fetch ( "http://localhost:3000/v1/characters " )
31
31
. then ( response => response . json ( ) )
32
32
. then ( ( data ) => {
33
33
this . friends = data ;
34
34
} )
35
35
} ,
36
36
template : `
37
- <div>
38
- <li v-for="friend, i in friends">
39
- <div v-if="editFriend === friend.id">
40
- <input v-on:keyup.13="updateFriend(friend)" v-model="friend.name" />
41
- <button v-on:click="updateFriend(friend)">save</button>
42
- </div>
43
- <div v-else>
44
- <button v-on:click="editFriend = friend.id">edit</button>
45
- <button v-on:click="deleteFriend(friend.id, i)">x</button>
46
- {{friend.name}}
47
- </div>
37
+ <ul class="list-group">
38
+ <div>
39
+ <li class="list-group-item" v-for="friend, i in friends">
40
+ <div v-if="editFriend === friend.id">
41
+ <input v-on:keyup.13="updateFriend(friend)" v-model="friend.name" />
42
+ <button class="btn btn-primary" v-on:click="updateFriend(friend)">save</button>
43
+ </div>
44
+ <div v-else>
45
+ <button class="btn btn-warning" v-on:click="editFriend = friend.id">edit</button>
46
+ <button v-on:click="deleteFriend(friend.id, i)">x</button>
47
+ {{friend.name}}
48
+ </div>
48
49
</li>
49
- </div>
50
+ </div>
51
+ </ul>
50
52
` ,
51
- } ) ;
53
+ } ) ;
0 commit comments