Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
rafw87 committed Oct 26, 2023
1 parent 13a3018 commit fff5fb0
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,31 @@ $ yarn add axios-url-template

## Usage

Importing library:
```typescript
import { urlTemplateInterceptor } from "axios-url-template";
```

// attaching interceptor to Axios global instance
Attaching interceptor to Axios global instance:
```typescript
axios.interceptors.request.use(urlTemplateInterceptor());
```

// passing options
Passing options:
```typescript
axios.interceptors.request.use(urlTemplateInterceptor({
urlAsTemplate: false,
}));
```

// attaching interceptor to Axios instance
Attaching interceptor to Axios instance
```typescript
const instance = axios.create({ /* ... */});
instance.interceptors.request.use(urlTemplateInterceptor());
```

// example requests

Example requests:
```typescript
const response1 = await axios.get('/test/{id}', {
urlTemplateParams: { id: 123 },
});
Expand Down

0 comments on commit fff5fb0

Please sign in to comment.