Step 1
Create a file called articles.js inside routes folder
Step 2
Save article like we did in user registration in Issue #7
keep author as null and comments as an empty array.
We will take author from logged in user later
Step 3
Add validations like we did in Issue #8
Step 4
Modify app.js to include articles routes
var articlesRouter = require('./routes/articles');
app.use('/articles', articlesRouter);
Step 5
Fetch a user from DB and set as a temporary user
Steps
Step 1 Create a file called articles.js inside routes folder
Step 2 Save article like we did in user registration in Issue #7 keep author as null and comments as an empty array. We will take author from logged in user later
Step 3 Add validations like we did in Issue #8
Step 4 Modify app.js to include articles routes
Step 5 Fetch a user from DB and set as a temporary user
const express = require('express'); const router = express.Router(); const bodyParser = require('body-parser');
const Articles = require('../models/articles'); const Users = require('../models/users');
const { check, validationResult } = require('express-validator');
router.use(bodyParser.json());