A Node.js microservice which determines the distance for specific zip codes.
Node.js; Express; Reuest; VSCode; Git; GitHub
standard operation
$ npm install express request --save
$ npm init
Creating a Server to Accept Requests; Defining the Routes; Adding Controller Logic
The call to a third-party API. We'll use the distance API provided by ZipCodeAPI.com. You need an API key to use this, and it is free if you register. You can also use the key from this example if you want to test your service in error condition because this key frequently expires during the day.
$ npm install
$ npm start
http://localhost:3000/about
http://localhost:3000/distance/84010/97229
The result should be as following if the API key is not expired.
{"distance":638.174}