-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
57 lines (39 loc) · 1.41 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const express = require("express");
const app = express();
// let bodyParser = require("body-parser");
// "http-server _site/ -c-1 -p $PORT"
app.set('view engine', "jekyll")
// app.use(bodyParser.urlencoded({ extended: true }));
// app.use(bodyParser.json());
app.use(express.static("_site"))
app.get("/", (request, response) => {
response.sendFile(__dirname + "/_site/index.html");
});
let withings = require("./_includes/js/withings.js")
app.get("/refresh", withings.refresh)
app.get("/daily", withings.daily)
const listener = app.listen(process.env.PORT, () => {
console.log("Your app is listening on port " + listener.address().port);
});
//CLIENT SIDE DOESNT WORK
// fetch(urlRefresh, {
// method: "OPTIONS",
// origin: "https://shequalifies.glitch.me",
// "Content-Type": "application/json",
// "Access-Control-Request-Method": "POST",
// "Access-Control-Request-Headers": "Authorization, Content-Type"
// }).then(res => {
// console.log(res)
// fetch(urlRefresh)
// // fetch(urlRefresh, options)
// .then(r => {JSON.parse(r)})
// .then(r => {
// console.log("new data " + r)
// // fs.writeFile('./data/oauth.json', r, (err) => {
// // if (err) throw err;
// // console.log('access token refreshed, saved');
// // });
// return r
// // makeRequest(urlRefresh, options, path, res) //customized
// }).catch(err => {console.log(err)})
// }).catch(err => {console.log(err)})