Skip to content

Commit 3cea681

Browse files
authored
Document how to customize client requests by setting fetch property (#96)
1 parent 91861b7 commit 3cea681

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,20 @@ const replicate = new Replicate({
131131
});
132132
```
133133

134+
You can override the `fetch` property to add custom behavior to client requests,
135+
such as injecting headers or adding log statements.
136+
137+
```js
138+
client.fetch = (url, options) => {
139+
const headers = new Headers(options && options.headers);
140+
headers.append("X-Custom-Header", "some value");
141+
142+
console.log("fetch", { url, ...options, headers });
143+
144+
return fetch(url, { ...options, headers });
145+
};
146+
```
147+
134148
### `replicate.models.get`
135149

136150
```js

0 commit comments

Comments
 (0)