Building the /transaction/:transactionId endpoint

Let's build the /transaction/:transactionId endpoint by using the getTransaction method that we built in the previous section. Let's begin:

  1. The first thing to do inside of this endpoint is to store the transaction ID sent as a request parameter. Let's store that in a transactionId variable, as follows:
app.get('/transaction/:transactionId', function(req, res) {         const transactionId = req.params.transactionId;});
  1. The next thing to do is use the getTransaction method inside of the endpoint. To do this, add the following to the preceding code: 
app.get('/transaction/:transactionId', function(req, res) {         const transactionId = req.params.transactionId;         bitcoin.getTransaction(transactionId); ...

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.