Complete Vue.js 2 Web Development_ Practical guide to building end-to-end web development solutions with Vue.js 2

(singke) #1

14


Vue Communicates with the


Internet


In this chapter, the following recipes will be covered:


Sending basic AJAX request with Axios
Validating user data before sending it
Creating a form and sending data to your server
Recovering from an error during a request
Creating a REST client (and server!)
Implementing infinite scrolling
Processing a request before sending it out
Preventing XSS attacks to your app

Introduction


Web applications rarely work all by themselves. What makes them interesting is actually
the fact that they enable us to communicate with the world in innovative ways that didn't


exist just a few years ago.


Vue, by itself, doesn't contain any mechanism or library to make AJAX requests or open


web sockets. In this chapter, we will, therefore, explore how Vue interacts with built-in


mechanisms and external libraries to connect to external services.


You will start by making basic AJAX requests with the help of an external library. Then,


you'll explore some common patterns with sending and getting data in forms. Finally, there
are some recipes with real-world applications and how to build a RESTful client.

Free download pdf