-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
52 lines (38 loc) · 1.06 KB
/
index.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const express = require('express')
const cricData= require('cric-player-info');
const bodyParser = require('body-parser')
const app = express()
app.use(bodyParser.urlencoded({extended:false}))
app.use(bodyParser.json())
app.set('view engine','ejs')
app.get('/',(req,res) =>{
res.render('index')
})
app.post('/getplayernames',(req,res) => {
console.log(req.body.input)
cricData.getMatchingPlayerNames(req.body.input).then((response)=>
{
console.log(JSON.stringify(response));
res.json({
names:response
})
})
})
app.post('/getplayerinfo',(req,res) =>{
console.log(req.body.playername)
cricData.getPlayerInfoByName(req.body.playername).then((response=>{
console.log(JSON.stringify(response));
res.json({
info:response
})
}))
.catch((err) =>{
console.log(err)
res.json({
info:"Player not found"
})
});
})
app.listen(5000,() =>{
console.log("App is listening on Port 5000")
})