From 26b93f500048aac2a3fbe67ee7bd21978a7c40c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gel=20=E2=9F=A8=5Cg=5C=E2=9F=A9?= Date: Tue, 10 May 2022 10:53:00 -0400 Subject: [PATCH 1/2] Create node-version-withAxios-2022 --- node-version-withAxios-2022 | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 node-version-withAxios-2022 diff --git a/node-version-withAxios-2022 b/node-version-withAxios-2022 new file mode 100644 index 0000000..ed97e4f --- /dev/null +++ b/node-version-withAxios-2022 @@ -0,0 +1,34 @@ +const express = require('express') +const app = express() +app.use(express.json()) +const port = 3000 +const axios = require('axios'); + +app.get('/', (req, res) => { + axios + .get('https://dog.ceo/api/breeds/list/all') + .then(async data => { + console.log(data.data) + await res.send(JSON.stringify(data.data)) + }) + .catch(error => { + console.error(error.message); + }); +}) + +app.get('/odata', (req, res)=> { + let serviceRoot = 'https://services.odata.org/v4/TripPinServiceRW/'; + + axios.get(`${serviceRoot}People`) + .then(async (data)=> { + console.log(data); + res.send(data.data.value) + }) + .catch(async (err)=> { + console.log(err) + }) +}) + +app.listen(port, () => { + console.log(`Example app listening on port ${port}`) +}) From d0d035037b6539642788f687f0fa48e664dffc72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gel=20=E2=9F=A8=5Cg=5C=E2=9F=A9?= Date: Tue, 10 May 2022 11:01:50 -0400 Subject: [PATCH 2/2] Update node-version-withAxios-2022 --- node-version-withAxios-2022 | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/node-version-withAxios-2022 b/node-version-withAxios-2022 index ed97e4f..b974c8b 100644 --- a/node-version-withAxios-2022 +++ b/node-version-withAxios-2022 @@ -5,18 +5,10 @@ const port = 3000 const axios = require('axios'); app.get('/', (req, res) => { - axios - .get('https://dog.ceo/api/breeds/list/all') - .then(async data => { - console.log(data.data) - await res.send(JSON.stringify(data.data)) - }) - .catch(error => { - console.error(error.message); - }); + res.send(`call routes "/odata_one" or "/odata_two"`); }) -app.get('/odata', (req, res)=> { +app.get('/odata_one', (req, res)=> { let serviceRoot = 'https://services.odata.org/v4/TripPinServiceRW/'; axios.get(`${serviceRoot}People`) @@ -29,6 +21,21 @@ app.get('/odata', (req, res)=> { }) }) + +app.get('/odata_two', (req, res)=> { + let serviceRoot = 'https://services.odata.org/v4/TripPinServiceRW/'; + let name = ('russellwhyte'); + + axios.get(`${serviceRoot}People('russellwhyte')`) + .then(async (data)=> { + console.log(data); + res.send(data.data) + }) + .catch(async (err)=> { + console.log(err) + }) +}) + app.listen(port, () => { console.log(`Example app listening on port ${port}`) })