blob: 9a336043eb27fb17da66e77147f9c84f0292a6db (
plain)
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
58
59
60
61
62
63
64
65
66
67
68
|
// const fs = require("fs");
const fs = require('node:fs');
// const https = require("https");
// var request = require('request-promise');
/*
var calls = [
request({
url: 'https://storage.googleapis.com/pythia-files/uploads/json/emarket-keywords.json',
// headers: { ... }
}),
request({
url: 'https://storage.googleapis.com/pythia-files/uploads/json/emarket-products.json',
// headers: { ... }
}),
// + linked-terms and replaces
// and more..
];
Promise.all(calls).then(function(results) {
// do something with results[0]
// do something with results[1]
// ...
});
*/
// write files into local fs; use them cached
/*
let file = fs.createWriteStream('../data/emarket-products.json');
https.get('https://storage.googleapis.com/pythia-files/uploads/json/emarket-products.json', response => {
var stream = response.pipe(file);
stream.on("finish", function() {
console.log("done");
});
});
var response = {
success: true,
products: 100,
ttl: + new Date()
}
*/
function create() {
var data = [];
for( let i = 0; i < (Math.floor(Math.random() * 100) +1) ; i++) {
data.push({ id: i, x5: i*5 });
}
console.log(data);
try {
fs.writeFileSync(__dirname + '/../data/j.json', JSON.stringify(data), 'utf-8');
// file written successfully
} catch (err) {
console.error(err);
}
}
module.exports = {
create
}
|