sandbox-gtfs-rt/node-axios-bindings-debug/index.js

42 lines
1.0 KiB
JavaScript

const axios=require('axios');
const gtfsRt = require('./gtfsRtDecode');
const debug = require('debug')('gtfs');
require('dotenv').config();
const URL=process.env.URL||'TODO: Adjust URL according to use case!'
debug('URL: '+URL)
run().catch(err => {
debug('run: error')
console.log(err)
});
async function run() {
debug('run started...')
const token = 'f5e9ef10f43095ce597cfa4b5c3b742475984b68';
const url = URL;
const usr = 'stefan2';
const ky = 'f5e9ef10f43095ce597cfa4b5c3b742475984b68';
const config = {
headers: {
authorization: `${token}`
},
// Axios looks for the `auth` option, and, if it is set, formats a
// basic auth header for you automatically.
//auth: {
// username: `${usr}`,
// password: `${ky}`
//},
responseType: 'arraybuffer'
//responseType: 'blob'
};
const res = await axios.get(URL,config);
//debug('run res: '+res);
//debug('run JSON res: '+JSON.stringify(res));
//debug('run res.data: '+res.data);
let feed=gtfsRt.decode(res.data);
debug('run done.')
}