feat(axios-get-trip): initial commit
This commit is contained in:
parent
0ba33eec8d
commit
f7ea9367a5
|
@ -0,0 +1,2 @@
|
||||||
|
NODE_ENV=development
|
||||||
|
URL=http://localhost:65534/trips?routeshortname=411
|
|
@ -0,0 +1,21 @@
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
tbc
|
||||||
|
|
||||||
|
## Preparation
|
||||||
|
Run the following command in your favorite terminal to install dependenies.
|
||||||
|
```
|
||||||
|
npm i
|
||||||
|
```
|
||||||
|
## Development setup
|
||||||
|
Run the following command in your favorite terminal if you fancy log messages for debugging.
|
||||||
|
```
|
||||||
|
export DEBUG=$DEBUG,axios
|
||||||
|
```
|
||||||
|
Run the following command in your favorite terminal to start the service in development mode.
|
||||||
|
```
|
||||||
|
npm run dev
|
||||||
|
```
|
||||||
|
## Production deployment
|
||||||
|
|
||||||
|
tbc
|
|
@ -0,0 +1,35 @@
|
||||||
|
require('dotenv').config();
|
||||||
|
const axios = require('axios');
|
||||||
|
const debug=require('debug')('axios');
|
||||||
|
|
||||||
|
const URL=process.env.URL;
|
||||||
|
debug('URL: '+URL)
|
||||||
|
|
||||||
|
run().catch(err => {
|
||||||
|
debug('run: error')
|
||||||
|
console.log(err)
|
||||||
|
});
|
||||||
|
|
||||||
|
async function run() {
|
||||||
|
debug('run:...')
|
||||||
|
|
||||||
|
//HTTP GET
|
||||||
|
let dataGet = await axios.get(
|
||||||
|
URL
|
||||||
|
//async example to process responce
|
||||||
|
// ).then(res => {
|
||||||
|
// debug('res.data: %s',res.data)
|
||||||
|
// });
|
||||||
|
);
|
||||||
|
|
||||||
|
debug('data received via GET');
|
||||||
|
debug('dataGet: %s',dataGet);
|
||||||
|
debug('dataGet.data.length: %s',dataGet.data.length);
|
||||||
|
debug('dataGet.data: %s',dataGet.data);
|
||||||
|
debug('dataGet.data[0].ageny_name: %s',dataGet.data[0].agency_name);
|
||||||
|
debug('dataGet.data[0].route_short_name: %s',dataGet.data[0].route_short_name);
|
||||||
|
debug('dataGet.data[0].agency_id: %s',dataGet.data[0].agency_id);
|
||||||
|
debug('dataGet.data[0].route_id: %s',dataGet.data[0].route_id);
|
||||||
|
debug('dataGet.data[0].service_id: %s',dataGet.data[0].service_id);
|
||||||
|
debug('dataGet.data[0].trip_id: %s',dataGet.data[0].trip_id);
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"name": "axios-get-trip",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "nodemon index.js",
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "Stefan Begerad",
|
||||||
|
"license": "GPL-3.0",
|
||||||
|
"devDependencies": {
|
||||||
|
"nodemon": "^2.0.7"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"axios": "^0.21.1",
|
||||||
|
"dotenv": "^8.2.0"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue