Skip to content

Commit 410bbf7

Browse files
authored
Merge pull request #70 from envoy/master-to-typescript
Resolve conflicts between master and typescript branches
2 parents bc1276c + 26f763d commit 410bbf7

File tree

6 files changed

+13710
-3584
lines changed

6 files changed

+13710
-3584
lines changed

.github/workflows/test.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: actions/setup-node@v2
12+
with:
13+
node-version: '16'
14+
- run: npm install
15+
- run: npm run test

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
14
1+
16

lib/axios.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const { AxiosError } = require('axios');
2+
const axios = require('axios');
3+
4+
function createAxiosClient(config) {
5+
const client = axios.create(config);
6+
client.interceptors.response.use(
7+
(response) => {
8+
return response
9+
},
10+
(error) => {
11+
const safeError = {
12+
code: error.code,
13+
response: {
14+
code: error.response?.code,
15+
status: error.response?.status,
16+
statusText: error.response?.statusText,
17+
data: error.response?.data,
18+
},
19+
message: error.message,
20+
name: error.name,
21+
baseURL: error.request?.baseURL ?? error.config?.baseURL,
22+
url: error.request?.url ?? error.config?.url,
23+
method: error.request?.method ?? error.config?.method,
24+
stack: error.stack,
25+
data: error.data,
26+
}
27+
return Promise.reject(safeError);
28+
},
29+
);
30+
31+
return client;
32+
}
33+
34+
module.exports = createAxiosClient;

0 commit comments

Comments
 (0)