From 0ba33eec8da04bea9e1cf31ddac09dec7ee50547 Mon Sep 17 00:00:00 2001 From: "Begerad, Stefan" Date: Tue, 17 May 2022 14:39:29 +0200 Subject: [PATCH] feat(axios-get): initial commit --- axios-auth/README.md | 14 +++----------- axios-auth/index.js | 2 +- axios-get/.env | 2 ++ axios-get/README.md | 21 +++++++++++++++++++++ axios-get/index.js | 30 ++++++++++++++++++++++++++++++ axios-get/package.json | 19 +++++++++++++++++++ 6 files changed, 76 insertions(+), 12 deletions(-) create mode 100644 axios-get/.env create mode 100644 axios-get/README.md create mode 100644 axios-get/index.js create mode 100644 axios-get/package.json diff --git a/axios-auth/README.md b/axios-auth/README.md index 01a1714..d85589f 100644 --- a/axios-auth/README.md +++ b/axios-auth/README.md @@ -1,8 +1,3 @@ -/* - * SPDX-FileCopyrightText: 2021 Stefan Begerad - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ ## Overview Download file using node.js inbuild packges. @@ -14,15 +9,12 @@ npm i ## Development setup Run the following command in your favorite terminal if you fancy log messages for debugging. ``` -export DEBUG=$DEBUG,dload +export DEBUG=$DEBUG,axios ``` Run the following command in your favorite terminal to start the service in development mode. ``` npm run dev ``` ## Production deployment -Run the following command in your favorite terminal to start the service for production mode. -``` -npm run start -``` -## Links + +tbc diff --git a/axios-auth/index.js b/axios-auth/index.js index 8a8301b..87d8d6b 100644 --- a/axios-auth/index.js +++ b/axios-auth/index.js @@ -18,7 +18,7 @@ if (process.env.NODE_ENV === 'development') { rejectUnauthorized: false, }) axios.defaults.httpsAgent = httpsAgent - debug('%s RejectUnauthorized is disabled.',process.env.NODE_ENV) + debug('%s mode, RejectUnauthorized is disabled.',process.env.NODE_ENV) } run().catch(err => { diff --git a/axios-get/.env b/axios-get/.env new file mode 100644 index 0000000..2aad8b0 --- /dev/null +++ b/axios-get/.env @@ -0,0 +1,2 @@ +NODE_ENV=development +URL=http://localhost:65534/agency-all diff --git a/axios-get/README.md b/axios-get/README.md new file mode 100644 index 0000000..e009617 --- /dev/null +++ b/axios-get/README.md @@ -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 diff --git a/axios-get/index.js b/axios-get/index.js new file mode 100644 index 0000000..cd3c7af --- /dev/null +++ b/axios-get/index.js @@ -0,0 +1,30 @@ +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); +} diff --git a/axios-get/package.json b/axios-get/package.json new file mode 100644 index 0000000..a03fe21 --- /dev/null +++ b/axios-get/package.json @@ -0,0 +1,19 @@ +{ + "name": "axios-get", + "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" + } +}