-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
38 lines (26 loc) · 901 Bytes
/
server.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
require('dotenv').config()
const express = require('express')
const cors = require("cors");
const axios = require('axios')
const app = express()
app.set('view engine', 'ejs');
app.set('views', 'views');
app.use(cors());
app.use(express.static("public"));
app.get('/', (req, res) => {
let auth = btoa(`${process.env.LOGIN_USERNAME}:${process.env.PASSWORD}`);
axios.get('https://fedskillstest.coalitiontechnologies.workers.dev', {
headers: {
'Authorization': `Basic ${auth}`
}
}).then(function (data) {
const patient = data.data[3]
const diagnosisHistory = patient.diagnosis_history
res.render('index', { patient, diagnosisHistory });
}).catch(error => {
console.error(error.data);
});
})
app.listen(process.env.PORT, () => {
console.log('Server started listening to port', process.env.PORT);
})