Toggle navigation
Toggle navigation
This project
Loading...
Sign in
I_Jemin
/
Node-Study
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
I_Jemin
2018-03-25 00:42:45 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
36a213646cdc45d0d5e0a98b354f87f423c8692d
36a21364
1 parent
dd741afe
Handling HTTP Post
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
express-demo/index.js
express-demo/index.js
View file @
36a2136
const
express
=
require
(
'express'
);
const
app
=
express
();
app
.
use
(
express
.
json
());
const
courses
=
[
{
id
:
1
,
name
:
'course1'
},
{
id
:
2
,
name
:
'course2'
},
...
...
@@ -27,6 +29,15 @@ app.get('/api/courses/:id',(req,res) => {
res
.
send
(
course
);
});
app
.
post
(
'/api/courses'
,(
req
,
res
)
=>
{
const
course
=
{
id
:
courses
.
length
+
1
,
name
:
req
.
body
.
name
}
courses
.
push
(
course
);
res
.
send
(
course
);
});
// PORT
const
port
=
process
.
env
.
PORT
||
3000
;
...
...
Please
register
or
login
to post a comment