-
Notifications
You must be signed in to change notification settings - Fork 0
/
boaRetreiveData.js
39 lines (35 loc) · 976 Bytes
/
boaRetreiveData.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
import dotenv from 'dotenv';
dotenv.config()
const url = 'https://api-sb.bofa.com/cashpro/reporting/v1/transaction-inquiries/current-day';
const ACCOUNT_NAME = '483102030472';
const BANK_ID = '021000322';
// Re-authorize each time
// import retrieve function here
const BOA_BEARER = process.env.BOA_API_KEY;
const data = {
'fromDate': '2024-05-21',
'toDate': '2024-05-22',
'accounts': [
{ accountNumber: ACCOUNT_NAME, bankId: BANK_ID }
]
};
fetch(url, {
method : 'POST',
headers : {
'Content-Type' : 'application/json',
'Authorization' : `Bearer ${BOA_BEARER}`,
},
body : JSON.stringify(data),
})
.then(response => {
if(!response.ok) {
throw new Error(`\nNetwork response is not ok, response code is ${response.status}: ${response.statusText}`);
}
return response.json();
})
.then(data => {
console.log(data);
})
.catch(error => {
console.error('You have an operational error', error)
})