-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
33 lines (25 loc) · 760 Bytes
/
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
const express = require("express");
const bodyParser = require("body-parser");
const fetch = require('node-fetch');
let port = process.env.PORT || 7070;
let app = express();
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended: false}))
app.use(express.static('public'));
app.get('/raiders', (req, res) => {
//http://localhost:8080/api/raiders
fetch(`${process.env.RAIDERS_SERVICE}`, {
method:'GET', headers: {"Content-Type": "application/json;charset=UTF-8"}
})
.then(response => {
return response.json();
})
.then(jsonData => {
res.send({raiders: jsonData});
})
.catch(error => {
res.send({error: error});
});
})
app.listen(port)
console.log("🌍 Discovery Server is started - listening on ", port)