File tree Expand file tree Collapse file tree 3 files changed +14
-21
lines changed
days/093-096-vuejs/movie_exploder Expand file tree Collapse file tree 3 files changed +14
-21
lines changed Original file line number Diff line number Diff line change @@ -204,24 +204,4 @@ genres_temp = [
204
204
"biography" ,
205
205
"comedy" ,
206
206
"crime" ,
207
- "documentary" ,
208
- "drama" ,
209
- "family" ,
210
- "fantasy" ,
211
- "film-noir" ,
212
- "game-show" ,
213
- "history" ,
214
- "horror" ,
215
- "music" ,
216
- "musical" ,
217
- "mystery" ,
218
- "news" ,
219
- "reality-tv" ,
220
- "romance" ,
221
- "sci-fi" ,
222
- "short" ,
223
- "sport" ,
224
- "thriller" ,
225
- "war" ,
226
- "western"
227
207
]
Original file line number Diff line number Diff line change 1
1
// noinspection ES6ModulesDependencies
2
2
3
+ const base_url = "http://movie_service.talkpython.fm/api/"
4
+
3
5
app = new Vue ( {
4
6
el : '#app' ,
5
7
data : {
@@ -12,13 +14,23 @@ app = new Vue({
12
14
methods : {
13
15
search : function ( ) {
14
16
let text = this . search_text
15
- console . log ( "Would have searched for " + text )
17
+ this . load_movies ( base_url + "search/ " + text )
16
18
} ,
17
19
top_10 : function ( ) {
18
20
console . log ( "Would have loaded top 10" )
19
21
} ,
20
22
load_genre : function ( genre ) {
21
23
console . log ( "Would load " + genre )
24
+ } ,
25
+ load_movies : function ( url ) {
26
+ let that = this
27
+ axios . get ( url )
28
+ . then ( function ( response ) { // handle success
29
+ that . movies = response . data . hits
30
+ } )
31
+ . catch ( function ( error ) { // handle error
32
+ console . log ( "ERROR! " + error ) ;
33
+ } )
22
34
}
23
35
}
24
36
} )
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ <h1>Movie Exploder</h1>
54
54
55
55
< script src ="../js/vue/vue.js "> </ script >
56
56
< script src ='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js '> </ script >
57
+ < script src ="https://unpkg.com/axios/dist/axios.min.js "> </ script >
57
58
< script src ="../js/fake_data.js "> </ script >
58
59
< script src ="../js/site.js "> </ script >
59
60
< script src ="../js/dropdown.js "> </ script >
You can’t perform that action at this time.
0 commit comments