Using the created lifecycle hook

- In the last video we successfully fetched some data…asynchronously and assigned values…to two properties in our Vue Instance.…But there are some things that I don't like…about this solution.…We just kind of slapped it down here at the bottom…and it's not really obvious at a glance why it's there…and there's no way for us to reuse it if we wanted to.…The first change I am going to make is to add a…method to our Vue Instance and put this code inside it.…Along with the API key and URL.…

(typing)…So in the methods object I'm gonna add fetchApod…which is a function that makes our asynchronous…request to the API.…And this is gonna need to know…about the API key and the URL.…

Once that's done we could just call…vm.fetchApod to get the same result.…That would be fine but now we still have…this dangling code down here that just…sort of looks like an after thought to the main attraction.…But how else can we call this method…as soon as our Vue Instance is created.…The answer is to use something called the hook.…So hook is an interface that can be used to…

Resume Transcript Auto-Scroll

Author

Released

10/19/2018

Have you found a primary JavaScript framework or library that suits your needs? If not, you might want to explore Vue.js, which offers a progressive approach to solving front-end problems. Vue is a sensible alternative to some of the more complex JavaScript frameworks, because it allows developers to add simple data binding to their views, but also incrementally progress to a full-blown single-page application if needed. In this course, Michael Sullivan introduces the Vue framework, explains which problems it aims to solve, and shows how to add Vue to a new or existing webpage. After he covers the key concepts and basic conventions of Vue, Michael dives into its component system, which can help you create modular, reusable code, and takes a look at the Vue CLI tool.