Skip to content

Commit

Permalink
feat(http-caching-proxy): replace usage of request with axios as http…
Browse files Browse the repository at this point in the history
… client

BREAKING CHANGE: [axios](https://github.com/axios/) is now used as the
http client package to replace [request](https://github.com/request/request)
which is now deprecated.
  • Loading branch information
raymondfeng committed Feb 18, 2020
1 parent db850b6 commit f3e55fa
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 460 deletions.
19 changes: 14 additions & 5 deletions packages/http-caching-proxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,22 @@ await proxy.start();
```

In your tests, configure the client library to use the caching proxy. Below is
an example configuration for [request](https://www.npmjs.com/package/request):
an example configuration for [axios](https://github.com/axios/axios):

```ts
request = request.defaults({
proxy: proxy.url,
// Disable tunneling of HTTPS requests - this is required for HTTPS!
tunnel: false,
const parsed = new URL(proxy.url);
const proxyConfig = {
host: parsed.hostname,
port: parseInt(parsed.port),
protocol: parsed.protocol,
auth: {
username: parsed.username,
password: parsed.password,
},
};
const request = axios.create({
// Axios does not support proxy url directly
proxy: proxyConfig,
});
```

Expand Down
Loading

0 comments on commit f3e55fa

Please sign in to comment.