Rudimentary api

Focus returns to server side. To make it easier nodemon was installed a dev dependency with npm install nodemon –save-dev and the start script in package.json has a “start”:”nodemon -w server.js server.js”, added so that changes to server.js restart node.

After that housekeeping, the data was moved to an array in server.js and a route added:

app.get('/api/issues',(req, res) => {
 const metadata = { total_count: issues.length };
 res.json({ _metadata: metadata, records: issues });
});

Then either with the browser pointed at http://localhost:3000/api/issues (checking the chromes developer tools set to the network->preview pane) or by using $ curl -s http://localhost:3000/api/issues | json_pp the response can be tested.

Leave a Reply

Your email address will not be published. Required fields are marked *