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

Getting ready


This recipe is fairly advanced in the sense that you will need to be comfortable with the
architecture of client and server and at least have heard or read about REST interfaces. You


will also need to be familiar with the command line and have npm installed. You can read
all about it in the Choosing a development environment recipe.


Axios will also need to be installed; read more about this in the first recipe of this chapter.


How to do it...


I remember when some years ago, building a REST server could take days or weeks. You


can use Feather.js, and it will be quick and (hopefully painless). Open a command line


and install it through npm with the following command:


npm install -g feathers-cli

After that, create a directory where you will run the server, go inside it, and launch


Feathers:


mkdir my-server
cd my-server
feathers generate app

Answer all the questions with default values. When the process finishes, type in the
following command to create a new resource:


feathers generate service

One of the questions is the name of the resource; call it messages, but other than that, use


the default for all the other questions.


Exit from the feathers-cli with the exit command and start your new server with the


following command:


npm start

After some seconds, your REST server should be started and should be listening on port



  1. Can you honestly say it was difficult?


The preceding sequence of commands works with Feathers version 2.0.0
It's totally possible that you may be using another version but it should
still be easy to get the same result with a later version; check the online
install guide at https:/​/​feathersjs.​com/​.
Free download pdf