sprint challenge complete Russell Stinson CSPT1#253
sprint challenge complete Russell Stinson CSPT1#253rcs784 wants to merge 1 commit intobloominstituteoftechnology:masterfrom
Conversation
|
|
||
| const expenseSchema = new Schema({ | ||
| amount: { | ||
| type: number, |
| @@ -0,0 +1,26 @@ | |||
| const mongoose = require('mongoose'); | |||
| const Schema = mongoose.Schema; | |||
| const objectId = Schema.Types.ObjectId; | |||
There was a problem hiding this comment.
objectId should be ObjectId since we're referring it as such on line 17 and 21.
| @@ -1,10 +1,94 @@ | |||
| const express = require('express'); // remember to install your npm packages | |||
| const express = require('express'); | |||
| const bodyParser = require('body-parser'); | |||
There was a problem hiding this comment.
As of version 4.16.0, Express has included a built-in JSON parsing middleware (https://expressjs.com/en/api.html#express.json). So we don't actually need body-parser anymore. We can just do this:
const express = require('express');
const server = express();
server.use(express.json());| server.get('/', (req, res) => res.send('API Running...')); | ||
|
|
||
| server.post('/budgets', (req, res) => { | ||
| const { title, budgetAmount } = req.body; |
There was a problem hiding this comment.
Since we're not using title and budgetAmount any where, we don't have to destructure the req.body object. Instead, just create your new Budget by passing req.body:
const budget = new Budget(req.body);|
Please make sure you're installing the required packages by doing the following. In your Git-Bash window: $ npm i express mongoose
$ npm i -D nodemon // this installs nodemon as a dev dependencyThen run your server: $ nodemon server.jsAnd test the endpoints with Postman. |
|
Good work, Russell! I really like the hard work you've been putting in lately! Let's keep that momentum going. 😊 |
No description provided.