4
4
5
5
> The lightweight Node.js HTTP client
6
6
7
- [ Full documentation] ( https://ethanent.github.io/phin/global.html ) | [ GitHub] ( https://github.com/ethanent/phin ) | [ NPM] ( https://www.npmjs.com/package/phin )
8
-
9
7
## Deprecated
10
8
11
9
This package is deprecated and should not be used. Please see [ #91 ] ( https://github.com/ethanent/phin/issues/91 ) for more information.
@@ -15,7 +13,7 @@ This package is deprecated and should not be used. Please see [#91](https://gith
15
13
``` javascript
16
14
const p = require (' phin' )
17
15
18
- const res = await p (' https://ethanent.me ' )
16
+ const res = await p (' https://example.com ' )
19
17
20
18
console .log (res .body )
21
19
```
@@ -42,7 +40,7 @@ Simple POST:
42
40
43
41
``` js
44
42
await p ({
45
- url: ' https://ethanent.me ' ,
43
+ url: ' https://example.com ' ,
46
44
method: ' POST' ,
47
45
data: {
48
46
hey: ' hi'
@@ -55,7 +53,7 @@ await p({
55
53
``` js
56
54
const p = require (' phin' ).unpromisified
57
55
58
- p (' https://ethanent.me ' , (err , res ) => {
56
+ p (' https://example.com ' , (err , res ) => {
59
57
if (! err) console .log (res .body )
60
58
})
61
59
```
@@ -66,7 +64,7 @@ Simple parsing of JSON:
66
64
// (In async function in this case.)
67
65
68
66
const res = await p ({
69
- ' url' : ' https://ethanent.me/name ' ,
67
+ ' url' : ' https://example.com/ ' ,
70
68
' parse' : ' json'
71
69
})
72
70
@@ -84,33 +82,25 @@ const ppostjson = p.defaults({
84
82
85
83
// In async function...
86
84
87
- const res = await ppostjson (' https://ethanent.me /somejson' )
85
+ const res = await ppostjson (' https://example.com /somejson' )
88
86
// ^ An options object could also be used here to set other options.
89
87
90
88
// Do things with res.body?
91
89
```
92
90
93
- ### Custom Core HTTP Options
91
+ ### Custom Axios HTTP Options
94
92
95
- Phin allows you to set [ core HTTP options] ( https://nodejs.org/api/http.html#http_http_request_url_options_callback ) .
93
+ Phin allows you to set [ Axios HTTP options] ( https://github.com/axios/axios?tab=readme-ov-file#request-config ) .
96
94
97
95
``` js
98
96
await p ({
99
- ' url' : ' https://ethanent.me /name' ,
100
- ' core ' : {
101
- ' agent ' : myAgent // Assuming you'd already created myAgent earlier.
97
+ ' url' : ' https://example.com /name' ,
98
+ ' axiosOpts ' : {
99
+ httpAgent : myAgent // Assuming you'd already created myAgent earlier.
102
100
}
103
101
})
104
102
```
105
103
106
-
107
- ## Full Documentation
108
-
109
- There's a lot more which can be done with the Phin library.
110
-
111
- See [ the Phin documentation] ( https://ethanent.github.io/phin/global.html ) .
112
-
113
-
114
104
## Phin vs. the Competition
115
105
116
106
Phin is a very lightweight library, yet it contains all of the common HTTP client features included in competing libraries!
0 commit comments