· 8 years ago · May 19, 2018, 06:00 AM
1//const axios = require('axios');
2//const sqlite3 = require('sqlite3').verbose();
3
4//let db = new sqlite3.Database('SERVICE');
5
6banks = [
7 {
8 id: 0,
9 name: 'Santander',
10 url: 'https://www.santander.cl',
11 status: 0,
12 error : '',
13 imgStatus: '',
14 txtStatus: ''
15 },
16 {
17 id: 1,
18 name: 'Banco de Chile',
19 url: 'https://duckduckgo.com',
20 status: 0,
21 error : '',
22 imgStatus: '',
23 txtStatus: ''
24 },
25 {
26 id: 2,
27 name: 'Banco UwU',
28 url: 'https://www.google.cl',
29 status: 0,
30 error : '',
31 imgStatus: '',
32 txtStatus: ''
33 },
34];
35/*
36function checkStatus(index, banco){
37 axios.get(banco.url).then(res => {
38 //console.log('is ' + banks[index].name + ' even working');
39 banco.status = res.status;
40 console.log('is ' + banco.name + ' even working: ' + banco.status);
41 //this.banks[index].imgStatus = okImg;
42 banco.txtStatus = 'Everything seems alright';
43 db.transaction(function (tx) {
44 'CREATE TABLE IF NOT EXISTS BankStatic (Id integer, Name text, Url text)'
45 }, errorCB, successCB);
46 } ).catch(err => {
47 //console.log(err);
48 //console.log('there is an error');
49 banco.error = err.message;
50 //this.banks[index].imgStatus = errorImg;
51 banco.txtStatus = 'There is an error';
52 });
53 //return banco.status
54}
55
56//db.transaction(function(tx){
57 //tx.executeSql('SELECT * FROM BankStatic');
58
59//});
60
61db.run('SELECT * FROM BankStatic;')
62let i;
63for (i = 0; i < banks.length;++i){
64 checkStatus(i, banks[i]);
65}
66*/