Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

shorten req.body. function

const { name, image, description, price, location, user } = req.body;
const author = { id: user._id, username: user._username };
const newCampground = { name, image, description, price, location, author };

// or, without the intermediate `author` variable:

const newCampground = { name, image, description, price, location, author: { id: user._id, username: user._username } };
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #shorten #function
ADD COMMENT
Topic
Name
8+6 =