-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (23 loc) · 684 Bytes
/
index.js
File metadata and controls
28 lines (23 loc) · 684 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// const express = require("express");
import express from 'express';
import data from './data.js'
const app = express();
// const PORT = 4000;
app.get("/movies", function (request, response) {
response.send(data);
});
app.get("/", function (request, response) {
response.send('Welcome !!!');
});
app.get("/movies/:id", function (request, response) {
const id=request.params.id;
const idData=data.find((e)=>e.id == id)
if(idData ==undefined){
response.status(404).send({
message:'data not found'
})
}else{
response.send(idData);
}
});
app.listen(process.env.PORT||4000, () => console.log(`The server started ✨✨`));