JavaScript and REST APIs
- 1 minThere are several Web services available on the internet. Many web services, like Twilio and Facebook, make their data accessible to third-party applications through an application programming interface (API). One of the most popular ways to build APIs is the REST(REpresentational Stateless Transfer) architecture style.
This post will be a good primer for a Java programmer looking to integrate any web-service APIs.
In this post, I shall show a working source code and a docker container image to get started quickly.
Use below two commands to see the example in action.
make build-container
make test-container
Purpose
Provide a sample example code for RESTful Web Services in JavaScript.
Installation
Please refer to Makefile and Dockerfile for install and build instructions.
make install
make build
make build-container
Resource
ExpressJS is one of the most popular HTTP server libraries for Node.js
- URIs
/event /events/:id
Restful Methods
- POST
app.post('/event', function (req, res))
- GET
app.get('/', function (req, res)) app.get('/events/:id', function (req, res)) app.get('/listUsers', function (req, res))
- PATCH
app.patch('/events/:id', function (req, res))
- DELETE
app.delete('/events/:id', function (req, res))
Testing
- Run Server
make build
- Run Client
make run make test-container
Next Steps
Follow the below links for the source code and Dockerfile
I hope that these references will make getting started extremely easy.
Enjoy!
Web Resources
DISCLAIMER: All views expressed on this site are my own and do not represent the opinions of any entity whatsoever with which I have been, am now, or will be affiliated. Any collateral used is referenced in the Web Resources or others sections on this page. The information provided on this website does not constitute investment advice, financial advice, or trading advice.