Skip to content

Commit

Permalink
Merge pull request #11 from dnullproject/fix-mono-api
Browse files Browse the repository at this point in the history
Fix monobank request errors
  • Loading branch information
prizrak1609 authored Feb 15, 2024
2 parents 5db4d32 + d3172ab commit 15bc1ad
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions mono_actual.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const actualApi = require('@actual-app/api');

const CACHE_DIR_PATH = '.cache/';
const MONO_URL = 'https://api.monobank.ua/';
const MONO_URL = 'https://api.monobank.ua';
const DAYS_TO_SYNC = parseInt(process.env.DAYS_TO_SYNC);
const DEFAULT_DAYS_SYNC = DAYS_TO_SYNC < 7 ? DAYS_TO_SYNC : 7;
const MONO_TOKEN = process.env.MONO_TOKEN;
Expand Down Expand Up @@ -89,12 +89,13 @@ async function fetch_data() {

async function fetchMonoData(card, startDateTimestamp, endDateTimestamp) {
try {
const response = await fetch(MONO_URL + '/personal/statement/' + card + '/' + startDateTimestamp + '/' + endDateTimestamp, {
const mono_url = MONO_URL + '/personal/statement/' + card + '/' + startDateTimestamp + '/' + endDateTimestamp;
const response = await fetch(mono_url, {
headers: { 'X-Token': MONO_TOKEN, },
});

if (!response.ok) {
throw new Error('API request failed');
throw new Error(mono_url + ' failed: ' + ' ' + response.status + ' ' + response.statusText);
}

const data = await response.json();
Expand Down

0 comments on commit 15bc1ad

Please sign in to comment.