Developing the /address/:address endpoint

Now, let's build the /address/:address endpoint and we'll use the getAddressData method inside of this endpoint. The /address/:address endpoint will be very similar to the /block/:blockHash and /transaction/:transactionId endpoints, so you shouldn't find it too challenging:

  1. The first thing that we want to do inside of the endpoint is to store the address in a variable:
app.get('/address/:address', function(req, res) {       const address = req.params.address;});
  1. The next thing that we want to do is use the getAddressData method to get all of the data for the given address. In order to do that, we will add the following highlighted code to the endpoint:
app.get('/address/:address', function(req, res) ...

Get Learn Blockchain Programming with JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.