Skip to content

Commit 0700b60

Browse files
committed
Remove axios in favor of fetch
Signed-off-by: kvmw <mshamsi@broadcom.com>
1 parent 0d77687 commit 0700b60

5 files changed

Lines changed: 9 additions & 110 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ node_modules/
55
.env
66
.env.*
77
!.env.development
8+
9+
.idea/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ For information on the Service Registry product in Tanzu Platform for Cloud Foun
1717
- Install dependencies
1818

1919
```
20-
npm install && cf push
20+
npm install
2121
```
2222

2323
- Push the `greeter-messages` application:

package-lock.json

Lines changed: 0 additions & 105 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/greeter/server.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import axios from 'axios';
21
import express from 'express';
32
import { env, eureka } from '@greeting/shared';
43

@@ -24,13 +23,17 @@ app.get('/hello', async (req, res) => {
2423

2524
const url = `https://${serviceHost()}/greeting?salutation=${salutation}&name=${name}`;
2625

27-
const response = await axios.get(`${url}`, {
26+
const response = await fetch(`${url}`, {
2827
headers: {
2928
Accept: 'text/plain',
3029
},
3130
});
3231

33-
res.send(response.data);
32+
if (!response.ok) {
33+
throw new Error(`HTTP error! Status: ${response.status}`);
34+
}
35+
36+
res.send(await response.text());
3437
});
3538

3639
app.listen(env.port, '0.0.0.0', () => {

packages/shared/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"type": "module",
77
"license": "Apache-2.0",
88
"dependencies": {
9-
"axios": "^1.10.0",
109
"dotenv": "^17.2.0",
1110
"eureka-js-client": "^4.5.0",
1211
"simple-oauth2": "^5.1.0"

0 commit comments

Comments
 (0)