-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
33 lines (30 loc) · 825 Bytes
/
app.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 cors = require('cors')
const axios = require('axios')
require('dotenv').config()
// middlewares
const app = express()
app.use(express.json())
app.use(cors())
app.set("view engine", "ejs")
// routes
app.get('/', (req, res) => {
let config = {
method: 'get',
url: `http://api.qubitro.com/v1/projects/${process.env.PROJECT_ID}/devices/${process.env.DEVICE_ID}/data?keys=LAT,LNG&period=1&limit=1`,
headers: {
'Authorization': `Bearer-${process.env.AUTHORIZATION}`
}
}
axios(config)
.then(function (response) {
res.render("map", {data: response.data.response[0]})
})
.catch(function (error) {
console.log(error)
})
})
// serve
app.listen(1234, () => {
console.log('Your app run at port 1234')
})