Skip to content

Commit

Permalink
doc: improve doc with pure esmodule
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonTian committed Apr 1, 2024
1 parent 8135d6d commit 2e5231e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,25 @@ npm install httpx --save

## Usage

```js
import * as httpx from 'httpx';
```

### Request URL

```js
(async function () {
const response = await httpx.request('http://www.baidu.com/');
const body = await httpx.read(response, 'utf-8');
console.log(body);
})();
const response = await httpx.request('http://www.baidu.com/');
const body = await httpx.read(response, 'utf-8');
console.log(body);
```

### Request SSE URL

```js
(async function () {
const response = await httpx.request('sse url');
for await (const event of httpx.readAsSSE(response)) {
console.log(event);
}
})();
const response = await httpx.request('sse url');
for await (const event of httpx.readAsSSE(response)) {
console.log(event);
}
```

## API
Expand Down Expand Up @@ -82,10 +82,10 @@ Consume the response data with async iterator.
## Using with http proxy

```js
const { SocksProxyAgent } = require('socks-proxy-agent');
const httpx = require('httpx');
import { SocksProxyAgent } from 'socks-proxy-agent';
import * as httpx from 'httpx';

httpx.request('http://www.baidu.com/', {
await httpx.request('http://www.baidu.com/', {
// pass a http proxy agent
agent: new SocksProxyAgent('socks://your_proxy_server:3001')
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/JacksonTian/httpx.git"
"url": "git+https://github.com/JacksonTian/httpx.git"
},
"author": "Jackson Tian",
"license": "MIT",
Expand Down

0 comments on commit 2e5231e

Please sign in to comment.