Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nodeassignment1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bhavyarani Suvarna
nodeassignment1
Commits
e4ff624c
Commit
e4ff624c
authored
4 months ago
by
Bhavyarani Suvarna
Browse files
Options
Downloads
Patches
Plain Diff
adding server file for getapi and post api
parent
a78630ad
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
server.js
+35
-0
35 additions, 0 deletions
server.js
with
35 additions
and
0 deletions
server.js
0 → 100644
+
35
−
0
View file @
e4ff624c
const
express
=
require
(
"
express
"
);
const
app
=
express
();
// Middleware to parse JSON data
app
.
use
(
express
.
json
());
const
PORT
=
3000
;
// GET API - Returns path param & query param
app
.
get
(
"
/user/:id
"
,
(
req
,
res
)
=>
{
const
pathParam
=
req
.
params
.
id
;
const
queryParam
=
req
.
query
.
name
;
res
.
json
({
message
:
"
GET API Response
"
,
pathParam
:
pathParam
,
queryParam
:
queryParam
,
});
});
// Array to store POST data
const
dataStore
=
[];
app
.
post
(
"
/data
"
,
(
req
,
res
)
=>
{
const
receivedData
=
req
.
body
;
dataStore
.
push
(
receivedData
);
res
.
json
(
dataStore
);
});
// Start the server
app
.
listen
(
PORT
,
()
=>
{
console
.
log
(
`Server is running on http://localhost:
${
PORT
}
`
);
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment