Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dawkaka authored Apr 14, 2024
1 parent d8ae46f commit a0ab046
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,36 @@ Simply wrap your axios instance with the APIToolkit observeAvios function.
```typescript
import { observeAxios } from 'apitoolkit-express';
import axios from 'axios';
import express from 'express';

const app = express();
const apitoolkitClient = APIToolkit.NewClient({ apiKey: '<API-KEY>' });
app.use(apitoolkitClient.expressMiddleware);

app.get('/', (req, res) => {
const response = await observeAxios(axios).get(`${baseURL}/users/123`);
res.send(response.data);
}
});

const response = await observeAxios(axios).get(`${baseURL}/user_list/active`);
```

If you're making requests to endpoints which have variable urlPaths, you should include a wildcard url of the path, so that apitoolkit groups the endpoints correctly for you on the dashboardL:

```typescript
import { observeAxios } from 'apitoolkit-express';
import axios from 'axios';
import express from 'express';

const response = await observeAxios(axios, '/users/{user_id}').get(`${baseURL}/users/user1234`);
const app = express();
const apitoolkitClient = APIToolkit.NewClient({ apiKey: '<API-KEY>' });
app.use(apitoolkitClient.expressMiddleware);

app.get('/', (req, res) => {
const response = await observeAxios(axios,'/users/{user_id}').get(`${baseURL}/users/123`);
res.send(response.data);
}
});
```

There are other optional arguments you could pass on to the observeAxios function, eg:
Expand Down

0 comments on commit a0ab046

Please sign in to comment.