-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean-script.js
More file actions
62 lines (56 loc) · 1.8 KB
/
clean-script.js
File metadata and controls
62 lines (56 loc) · 1.8 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
51
52
53
54
55
56
57
58
59
60
61
const axios = require('axios')
const client = axios.create({
baseURL: "http://localhost:8080",
});
const budgetId = "My-Finances-daf819a";
client.post('/_load-budget', {
budgetId
}).then(() => {
console.log(`selected budget ${budgetId}`);
client
.get(`/accounts`)
.then(({ data: accounts }) => {
console.log(accounts)
for (let account of accounts) {
console.log(account)
client.post(`/accounts/${account.id}/close`, {}).then(res => {
console.log(res)
}).catch((error) => {
console.error(error)
})
}
})
.catch(console.error);
client.get('/payees').then(({ data: payees }) => {
console.log(payees)
for (let payee of payees) {
if (payee.transfer_acct === null) {
client.delete(`/payees/${payee.id}`).then(res => {
console.log(res)
}).catch((error) => {
console.error(error)
})
}
}
})
client.get('/categories').then(({ data: categories }) => {
console.log(categories)
for (let category of categories) {
client.delete(`/categories/${category.id}`).then(res => {
console.log(res)
}).catch((error) => {
console.error(error)
})
}
})
client.get('/category-groups').then(({ data: categoryGroups }) => {
console.log(categoryGroups)
for (let categoryGroup of categoryGroups) {
client.delete(`/category-groups/${categoryGroup.id}`).then(res => {
console.log(res)
}).catch((error) => {
console.error(error)
})
}
})
})