Skip to content

Commit 13a6994

Browse files
committed
Now searching via the API not test data.
1 parent 920bf86 commit 13a6994

File tree

3 files changed

+14
-21
lines changed

3 files changed

+14
-21
lines changed

days/093-096-vuejs/movie_exploder/js/fake_data.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -204,24 +204,4 @@ genres_temp = [
204204
"biography",
205205
"comedy",
206206
"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"
227207
]

days/093-096-vuejs/movie_exploder/js/site.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// noinspection ES6ModulesDependencies
22

3+
const base_url = "http://movie_service.talkpython.fm/api/"
4+
35
app = new Vue({
46
el: '#app',
57
data: {
@@ -12,13 +14,23 @@ app = new Vue({
1214
methods: {
1315
search: function () {
1416
let text = this.search_text
15-
console.log("Would have searched for " + text)
17+
this.load_movies(base_url + "search/" + text)
1618
},
1719
top_10: function () {
1820
console.log("Would have loaded top 10")
1921
},
2022
load_genre: function (genre) {
2123
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+
})
2234
}
2335
}
2436
})

days/093-096-vuejs/movie_exploder/views/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ <h1>Movie Exploder</h1>
5454

5555
<script src="../js/vue/vue.js"></script>
5656
<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>
5758
<script src="../js/fake_data.js"></script>
5859
<script src="../js/site.js"></script>
5960
<script src="../js/dropdown.js"></script>

0 commit comments

Comments
 (0)