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

(singke) #1
Vue Communicates with the Internet Chapter 14

Launch your application and you will be able to manage your board of sticky messages:


To prove to yourself that you are really communicating with the server, you can refresh the


page or close and reopen the browser and your notes will still be there.


How it works...


REST means REpresentational State Transfer, as in you will transfer a representation of


the state of some resource. In practice, we are using a set of verbs to transfer the
representation of the state of our messages.


Using the HTTP protocol, we have at our disposal the following verbs:


Verb Properties Description
GET Idempotent, safeUsed to retrieve the representation of a resource
POST Used to upload a new resource
PUT Idempotent Used to upload an existing resource (to modify it)
DELETEIdempotent Used to delete a resource

Idempotent means that if we use the same verb twice, nothing will happen to the resource,
and safe means that nothing will happen at all.


In our application, we use the GET verb only at the beginning during creation. When we


see the list changing as a result of the other actions, it is only because we are mirroring the
actions on the server on the frontend.

Free download pdf