Consuming the API
Now we will explore how to consume this API. We have seen that the API is contained in: localhost:3000/api/, and our root path only has some information regarding the API, as we can see by visiting localhost:3000:
{ started: "2016-05-15T15:20:24.779Z", uptime: 7.017 }
Let's change the root.js and middleware.json files and use some client side libraries to interact with the API.
Adding HTML content to client side
- Change the name of the root.js file inside server/boot to _root.js.
- Open middleware.json from server/ folder and add the following highlighted code:
{ "initial:before": { "loopback#favicon": {} }, "initial": { ... }, "helmet#xssFilter": {}, "helmet#frameguard": { ... }, "helmet#hsts": { ... }, "helmet#hidePoweredBy": {}, ...
Get Node.js 6.x Blueprints 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.