Comments (1)
Actually in addTransaction he destructures text and amount of req.body but never uses either text or amount. So in fact in this example the destructuring is useless and not needed at all.
exports.addTransaction = async (req, res, next) => {
try {
const { text, amount } = req.body;
const transaction = await Transaction.create(req.body);
as you see, he passes req.body straight into the Transaction.create. Which is actually the most direct way to do it in this case.
Presumably as the app grows and there was more in req.body you could pass in only the destructured variables needed.
from expense-tracker-mern.
Related Issues (6)
- Proxy error: Could not proxy request /api/v1/transactions from localhost:3000 to http://localhost:5000. HOT 4
- Console warning for unique key prop on TransactionList HOT 1
- Showing updated list on hard refresh after delete call front front end. HOT 1
- Error: Invalid connection string. HOT 2
- Deployment issue HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from expense-tracker-mern.