April 2020
Intermediate to advanced
716 pages
18h 55m
English
The create order API in the backend will take a POST request from the frontend to create the order in the database. The API route will be declared in server/routes/order.routes.js, along with the other order routes. These order routes will be very similar to the user routes. To load the order routes in the Express app, we need to mount the routes in express.js, just like we did for the auth and user routes.
mern-marketplace/server/express.js:
app.use('/', orderRoutes)
A number of actions, in the following sequence, take place when the create order API receives a POST request at /api/orders/:userId: