Skip to Content
Full-Stack React Projects - Second Edition
book

Full-Stack React Projects - Second Edition

by Shama Hoque
April 2020
Intermediate to advanced
716 pages
18h 55m
English
Packt Publishing
Content preview from Full-Stack React Projects - Second Edition

The create auction API

For the implementation of the backend API, which will allow us to create a new auction in the database, we will declare a POST route, as shown in the following code.

mern-marketplace/server/routes/auction.routes.js:

router.route('/api/auctions/by/:userId')  .post(authCtrl.requireSignin, authCtrl.hasAuthorization,         userCtrl.isSeller, auctionCtrl.create)

A POST request to this route at /api/auctions/by/:userId will ensure the requesting user is signed in and is also authorized. In other words, it is the same user associated with the :userId specified in the route param. Then, before creating the auction, it is checked if this given user is a seller using the isSeller method that's defined in the user controller methods. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Full-Stack React Projects

Full-Stack React Projects

Shama Hoque
React Native - The Practical Guide

React Native - The Practical Guide

Academind by Maximilian Schwarzmüller GmbH

Publisher Resources

ISBN: 9781839215414Supplemental Content