Refactoring the /transaction endpoint

We're going to refactor the /transaction endpoint in this section, so that it works perfectly with the new /transaction/broadcast endpoint. Let's apply the following steps to modify the endpoint:

  1. To get started, go to the dev/networkNode.js file and delete everything that is in the /transaction endpoint. The only time the /transaction endpoint will be hit is when the broadcast takes place. When the /transaction endpoint is being hit, the newTransaction variable will be sent as data. This condition can be defined as follows: 
app.post('/transaction', function(req, res) {    const newTransaction = req.body; };

In the preceding highlighted line, the newTransaction variable is sent to the /transaction endpoint ...

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.