Go Pro Sign Up Login
0 days 0 hrs 0 min 0 sec

Summer Sale

50% off Level Up Pro until you unsubscribe.
Get access to ALL 128 courses on Level Up Tutorials

This is your last chance to get Level Up Pro for $145/year.

or Learn More
Moon Moon

Buy Now and unlock this series

$

39

.99

$

24

.99

yours forever

Become a Pro and unlock everything

$

24

.99

per month

Route Based API Calls

In this series, we dive into VueJS. I teach you all about the basics of Vue app development where we dive into VueJS fundamentals, VueJS Animations, API calls, Vue Router and much more!

Vue (pronounced /vjuː/, like view) is a progressive framework for building user interfaces. Unlike other monolithic frameworks, Vue is designed from the ground up to be incrementally adoptable. The core library is focused on the view layer only, and is easy to pick up and integrate with other libraries or existing projects. On the other hand, Vue is also perfectly capable of powering sophisticated Single-Page Applications when used in combination with modern tooling and supporting libraries.

Downloads

Become a pro to download code and videos

Comments

dgloria

over 2 years ago

@Ryan Thanks, that's correct.

User avatar

Ryan

over 2 years ago [edited]

Noticed that the style computed property was firing before the movie data is returned. Receive the following error on page load, but the backdrop image is still loaded:

GET http://image.tmdb.org/t/p/w1280/undefined 404 (Not Found)

After placing breakpoints on styles() and fetchData(), I saw that the computed property was analyzed on page load, fetchData() was fired retrieving the movie data, and the computed property was updated using the new this.movie.backdrop_path. Was able to write a quick undefined check and remove the initial load error:

computed : {
  styles() {
    return {
      background: this.movie.backdrop_path ? `url(${BACKDROP_PATH}${this.movie.backdrop_path}) no-repeat`: ''
    };
  },
}

While initially skeptical that this was the right approach, the Vuejs Docs on Computed Properties explains the nature of how computed properties work by updating based on its dependencies. Due to the nature of how we're using styles immediately, this seems like an acceptable way integrate error handling.

Want to join the conversation?

Become a Pro member today!