mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-11 12:43:09 -05:00
Use an IIAFE in the API example code
This commit is contained in:
@@ -31,25 +31,27 @@ Next, you’ll need connect to your running server version of Actual to access y
|
||||
```js
|
||||
let api = require('@actual-app/api');
|
||||
|
||||
await api.init({
|
||||
// Budget data will be cached locally here, in subdirectories for each file.
|
||||
dataDir: '/some/path',
|
||||
// This is the URL of your running server
|
||||
serverURL: 'http://localhost:5006',
|
||||
// This is the password you use to log into the server
|
||||
password: 'hunter2',
|
||||
});
|
||||
(async () => {
|
||||
await api.init({
|
||||
// Budget data will be cached locally here, in subdirectories for each file.
|
||||
dataDir: '/some/path',
|
||||
// This is the URL of your running server
|
||||
serverURL: 'http://localhost:5006',
|
||||
// This is the password you use to log into the server
|
||||
password: 'hunter2',
|
||||
});
|
||||
|
||||
// This is the ID from Settings → Show advanced settings → Sync ID
|
||||
await api.downloadBudget('1cfdbb80-6274-49bf-b0c2-737235a4c81f');
|
||||
// or, if you have end-to-end encryption enabled:
|
||||
await api.downloadBudget('1cfdbb80-6274-49bf-b0c2-737235a4c81f', {
|
||||
password: 'password1',
|
||||
});
|
||||
// This is the ID from Settings → Show advanced settings → Sync ID
|
||||
await api.downloadBudget('1cfdbb80-6274-49bf-b0c2-737235a4c81f');
|
||||
// or, if you have end-to-end encryption enabled:
|
||||
await api.downloadBudget('1cfdbb80-6274-49bf-b0c2-737235a4c81f', {
|
||||
password: 'password1',
|
||||
});
|
||||
|
||||
let budget = await api.getBudgetMonth('2019-10');
|
||||
console.log(budget);
|
||||
await api.shutdown();
|
||||
let budget = await api.getBudgetMonth('2019-10');
|
||||
console.log(budget);
|
||||
await api.shutdown();
|
||||
})();
|
||||
```
|
||||
|
||||
Heads up! You probably don’t want to hard-code the passwords like that, especially if you’ll be using Git to track your code. You can use environment variables to store the passwords instead, or read them in from a file, or request them interactively when running the script instead.
|
||||
|
||||
Reference in New Issue
Block a user