Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,20 @@ import fetch from "cross-fetch";
const replicate = new Replicate({ fetch });
```

You can override the `fetch` property to add custom behavior to client requests,
You can also use the `fetch` option to add custom behavior to client requests,
such as injecting headers or adding log statements.

```js
replicate.fetch = (url, options) => {
const customFetch = (url, options) => {
const headers = options && options.headers ? { ...options.headers } : {};
headers["X-Custom-Header"] = "some value";

console.log("fetch", { url, ...options, headers });

return fetch(url, { ...options, headers });
};

const replicate = new Replicate({ fetch: customFetch });
```

### `replicate.run`
Expand Down