A simple NodeJS server for testing
To test our network communications, it seems fitting that we implement a small server using Node.js to implement the endpoints that we are testing. In a separate directory from our Vue application, open a terminal window and enter the following command:
$ npm init
The command-line wizard will ask you a few questions to create the package.json
file that represents a Node.js application. When it is done, run this command to install the Express.js dependency, which will give us a framework to create a web server:
$ npm install express cors
Once the process completes, create an index.js
file with the following code:
./server/index.js
const express = require("express") //1 const cors=require("cors") ...