Implementing the Customer Model Controller

Listing 28.11 implements the route handling code for the Customer model. There are four routes. The getCustomer() route finds a customer order, based on the hard-coded customerA value. If it is successful, the Customer object is returned to the client as JSON strings. If the request fails, a 404 error is returned. The updateShipping() route creates a new Address object from the updatedShipping parameter in the POST request and then uses an update() method to update the Customer object with the new shipping data. If it is successful, a success message is returned; if it fails, a 404 error is returned.

The updateBilling() route creates a new Billing object from the updatedBilling parameter in the POST ...

Get Node.js, MongoDB, and AngularJS Web Development 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.