-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset.js
40 lines (36 loc) · 1.22 KB
/
reset.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
// File used to reset the data.json to help testing
const fs = require('fs');
const filePath = __dirname + "/src/server/data.json"
const encoding = 'utf8'
const fileData =
[
{
"title": "HTTPS Potter and the API",
"author": "A.P.I Rowling",
"description": "Follows the adventure of HTTPS Potter. You're an Endpoint, HTTPS!",
"id": "1"
},
{
"title": "Hidden Mystery of the API",
"author": "Joona Jokivuori",
"description": "A book related to the mysterious world of API's.",
"id": "2"
},
{
"title": "Believing the API",
"author": "Put Post",
"description": "How could an ordinary man be helpful at all in this situation. No turning back now though.",
"id": "3"
},
{
"title": "Stranger of the API",
"author": "John Smith",
"description": "The laid-back life of a teenage boy will be changed completely as a strange boy enters his life.",
"id": "4"
}
]
fs.writeFile(filePath, JSON.stringify(fileData, null, 2), encoding, err => {
if (err) {
throw err;
}
});