This code worked & tested on node version v15.6.0.
Tested by Mac OS & Ubuntu-16.04.7.
If you don't have node, please install it.
In Ubuntu:
$ sudo apt-get update
$ sudo apt-get install -y build-essential
$ sudo apt-get install -y nodejs
Then check version:
$ node -v
In order to clone the source from github, please install git.
In Ubuntu:
$ sudo apt install git
Then clone the code:
$ git clone https://github.com/urosaria/node_express_api.git
Then follow:
$ cd node_express_api
$ npm install
$ node bin/www
You can check API in your browser: http://{{host}}:3000/
This API provides a random list of members from backend server.
http://{{host}}:3000/
Default list:
http://{{host}}:3000/
Users by dept:
http://{{host}}:3000/dept/:dept
Example: http://127.0.0.1:3000/dept/IT
':dept' could be IT, Marketing, HR, Sales.
{
"users": [
{
"name": "Zachary Ouellet",
"dept": "Sales",
"position": "Manager",
"email": "zachary.ouellet@example.com",
"picture": "https://randomuser.me/api/portraits/men/63.jpg",
"location": {
"street": {
"number": 5836,
"name": "Oak St"
},
"city": "Armstrong",
"state": "Newfoundland and Labrador",
"country": "Canada",
"postcode": "B9C 3S9",
"coordinates": {
"latitude": "-60.9028",
"longitude": "-88.6122"
},
"timezone": {
"offset": "+5:45",
"description": "Kathmandu"
}
},
"desc": "Zachary Ouelletis a Manager of Sales department. The primary responsibility is to sell an organisation’s services and products."
},
...
]
}