-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuploadFakeActivity.js
More file actions
50 lines (39 loc) · 1.08 KB
/
uploadFakeActivity.js
File metadata and controls
50 lines (39 loc) · 1.08 KB
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
const dotenv = require('dotenv');
var result = require('dotenv').config();
var moment = require('moment');
const fetch = require('node-fetch');
const api_url = process.env.API_URL;
const api_secret = process.env.API_SECRET;
module.exports = function run() {
const date = Date.now();
let steps = Math.round(Math.random() * 300);
console.log(steps);
var stepsToUpload = {
created_at : moment(date).toISOString(),
steps : steps,
secret: api_secret
} ;
console.log(stepsToUpload);
let heartRate = Math.round(50 + Math.random() * 50);
console.log(heartRate);
var heartRateToUpload = {
created_at : moment(date).toISOString(),
heartRate: heartRate,
secret: api_secret
} ;
console.log(heartRateToUpload);
fetch(api_url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(stepsToUpload),
});
fetch(api_url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(heartRateToUpload),
});
};