Skip to content

Commit

Permalink
Created POST route to /students/pd_skills endpoint (MUST ADD profile …
Browse files Browse the repository at this point in the history
…key and value for validation)
  • Loading branch information
sadatakhtar committed Nov 18, 2020
1 parent 3ac4fac commit 57223bb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/db/fakeData.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,6 @@ export const users = [

];


export const pdSkillsPostData = [];


17 changes: 16 additions & 1 deletion src/routes/students/controllers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {studentProfile, studentProgressTracker} from '../../db/fakeData';
import {studentProfile, studentProgressTracker, pdSkillsPostData} from '../../db/fakeData';
export const studentTracker = async (req, res) => {
try {
return res
Expand All @@ -24,3 +24,18 @@ export const getStudentProfile = async (req, res) => {
return res.status(400).send("Could not get students");
}
};

export const postPdSkills = async (req, res) => {
try {
let myPdPost = req.body;
!myPdPost.profile ? res.send('invalid data schema, need to add profile within POST!') : (pdSkillsPostData.push(myPdPost), res.status(200).json(myPdPost));





} catch (err) {
console.log(err);
return res.status(400).send("Could not get students Pd skills data");
}
};
4 changes: 3 additions & 1 deletion src/routes/students/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import express from "express";

import {
studentTracker,
getStudentProfile
getStudentProfile,
postPdSkills
} from "./controllers";

const router = express.Router();

// localhost:3001/students
router.get("/tracker", studentTracker);
router.get("/profile/:profile_id", getStudentProfile);
router.post("/pd_skills", postPdSkills);

export default router;

0 comments on commit 57223bb

Please sign in to comment.