June 2014
Intermediate to advanced
696 pages
38h 52m
English
Listing 28.10 implements the route handling code for the Order model. There are three routes. The getOrder() route finds a single order, based on the orderId included in the query. The getOrders() route finds all orders that belong to the current user. In this example, userid is hard-coded customerA. If the requests are successful, the order or all of this customer’s orders are returned to the client as JSON strings. If the requests fails, a 404 error is returned.
The addOrder() route handler builds a new Order object by getting the updated-Shipping, updatedBilling, and orderItems parameters from the POST request. If the order saves successfully, the cart field in the Customer object is reset to empty, ...
Read now
Unlock full access