Full-Stack Web Development with Vue.js and Node by Sharma Aneeta;

Full-Stack Web Development with Vue.js and Node by Sharma Aneeta;

Author:Sharma, Aneeta; [Aneeta Sharma]
Language: eng
Format: epub
Publisher: Packt Publishing, Limited
Published: 2018-05-14T10:16:58+00:00


export default {

name: 'Movie',

data() {

return {

movie: [],

};

},

mounted() {

this.fetchMovie();

},

methods: {

async fetchMovie() {

return axios({

method: 'get',

url: `http://localhost:8081/api/movies/${this.$route.params.id}`,

})

.then((response) => {

this.movie = response.data;

})

.catch(() => {

});

},

},

};

</script>

We have added an axios request here to fetch the movie when a user clicks on the title of the movie.

Now, we also need to define the routes to the page. So, in routes/index.js, replace the content with the following:

import Vue from 'vue';

import Router from 'vue-router';

import Home from '@/components/Home';

import Contact from '@/components/Contact';

import AddMovie from '@/components/AddMovie';

import Register from '@/components/Register';

import Login from '@/components/Login';

import Movie from '@/components/Movie';



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.