Skip to content

Commit

Permalink
post requests
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisPrescott707 committed May 3, 2020
1 parent 8983818 commit 75e6a73
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ const express = require('express');

const app = express();

app.use(express.json()) // for parsing application/json
app.use(express.urlencoded({ extended: true })) // for parsing application/x-www-form-urlencoded

app.get('/courses', (req, res) => {
res.status(200).json({ name: 'api testing' });
});

app.get('/course', (req, res) => {
let name = req.query.name;

res.json({ id: '1', name: name });
});

Expand All @@ -21,4 +23,14 @@ app.get('/course/:id', (req, res) => {
res.json({ id: id, name: name });
});

app.post('/course', (req, res) => {
let name = req.body.name;
res.json({ id: '2', name: name });
});

app.post('/course', (req, res) => {
let name = req.body.name;
res.json({ id: '2', name: name });
});

module.exports = app;

0 comments on commit 75e6a73

Please sign in to comment.