Book Image

Vue.js 2 Cookbook

By : Andrea Passaglia
Book Image

Vue.js 2 Cookbook

By: Andrea Passaglia

Overview of this book

Vue.js is an open source JavaScript library for building modern, interactive web applications. With a rapidly growing community and a strong ecosystem, Vue.js makes developing complex single page applications a breeze. Its component-based approach, intuitive API, blazing fast core, and compact size make Vue.js a great solution to craft your next front-end application. From basic to advanced recipes, this book arms you with practical solutions to common tasks when building an application using Vue. We start off by exploring the fundamentals of Vue.js: its reactivity system, data-binding syntax, and component-based architecture through practical examples. After that, we delve into integrating Webpack and Babel to enhance your development workflow using single file components. Finally, we take an in-depth look at Vuex for state management and Vue Router to route in your single page applications, and integrate a variety of technologies ranging from Node.js to Electron, and Socket.io to Firebase and HorizonDB. This book will provide you with the best practices as determined by the Vue.js community.
Table of Contents (19 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Dedication
Preface

Recovering from an error during a request


Requests to an external service take ages from the perspective of a computer. In human terms, it would be like sending a satellite to Jupiter and waiting for it to come back to Earth. You can't be 100% sure that the travel will ever be complete and how much time will the travel actually take. Networks are notoriously flacky and it's better to come prepared in case our request does not complete successfully.

 

Getting ready

This recipe is a little complex, but, does not use advanced concepts. You are expected, nonetheless, to be familiar with using Vue.

We will be using Axios for this recipe. You can complete the Sending basic AJAX requests with Axios recipe if you are unsure of what it exactly entails.

How to do it...

You will build a website for ordering pizzas on Mt. Everest. The area has notoriously poor Internet connection, so we may want to retry a couple of times before giving up on our pizza.

This is what our HTML looks like:

<div id="app">...