Skip to content

Commit

Permalink
Feat: Create a method to send the courses to db
Browse files Browse the repository at this point in the history
create addCourses in meta.js
move meta.js from libs to courses
install axios
imported in index for testing purposes
  • Loading branch information
akhilalekha committed May 5, 2021
1 parent 0509c48 commit 69b5992
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 34 deletions.
48 changes: 48 additions & 0 deletions website/courses/meta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import axios from "axios";
let courses = [
{
courseId: 1,
courseName: "javascript",
chapters: [
{
chapterId: 1,
chapterUrl: "introduction",
chapterName: "Introduction"
},
{
chapterId: 2,
chapterUrl: "hello-world",
chapterName: "Hello World"
},
{
chapterId: 3,
chapterUrl: "variables",
chapterName: "Variables"
},
{
chapterId: 4,
chapterUrl: "datatypes",
chapterName: "Datatypes"
},
{
chapterId: 5,
chapterUrl: "logical-operators",
chapterName: "Logical Operators"
},
{
chapterId: 6,
chapterUrl: "if-condition",
chapterName: "If Condition"
}
]
}
];

async function addCourses() {
// console.log("in add courses");
axios
.post("http://localhost:8080", courses)
.then((res) => console.log("sent courses", res.data))
.catch((err) => console.log(err));
}
export { courses, addCourses };
34 changes: 0 additions & 34 deletions website/lib/meta.js

This file was deleted.

41 changes: 41 additions & 0 deletions website/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@codemirror/theme-one-dark": "^0.18.0",
"@codemirror/view": "^0.18.7",
"@heroicons/react": "^1.0.1",
"axios": "^0.21.1",
"fs": "0.0.1-security",
"gray-matter": "^4.0.2",
"highlight.js": "^10.7.2",
Expand Down
2 changes: 2 additions & 0 deletions website/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Layout from "../component/layout/Layout.jsx";
import { addCourses } from "../courses/meta";

export default function Home() {
// addCourses();
return <Layout></Layout>;
}

0 comments on commit 69b5992

Please sign in to comment.