11# node-libcurl<!-- omit in toc -->
22
3+ <p align =" center " >
34<a href =" https://www.patreon.com/bePatron?u=19985213 " data-patreon-widget-type =" become-patron-button " >
4- <img src =" https://c5.patreon.com/external/logo/become_a_patron_button@2x.png " width =" 160 " >
5+ <img src =" https://c5.patreon.com/external/logo/become_a_patron_button@2x.png " width =" 190 " >
56</a >
6- <br >
7+ </ p >
78
89[ ![ NPM version] [ npm-image ]] [ npm-url ]
910[ ![ node] [ node-image ]] [ node-url ]
3637
3738- [ Quick Start] ( #quick-start )
3839 - [ Install] ( #install )
39- - [ Simple Request - Async / Await] ( #simple-request---async--await )
40- - [ Simple Request] ( #simple-request )
41- - [ Setting HTTP headers] ( #setting-http-headers )
40+ - [ Simple Request - Async / Await using curly ] ( #simple-request---async--await-using-curly )
41+ - [ Simple Request - Using Curl class ] ( #simple-request---using-curl-class )
42+ - [ Setting HTTP headers] ( #setting-http-headers )
4243 - [ Form Submission (Content-Type: application/x-www-form-urlencoded)] ( #form-submission-content-type-applicationx-www-form-urlencoded )
4344 - [ MultiPart Upload / HttpPost libcurl Option (Content-Type: multipart/form-data)] ( #multipart-upload--httppost-libcurl-option-content-type-multipartform-data )
4445- [ API] ( #api )
7071``` shell
7172yarn add node-libcurl
7273```
73- ### Simple Request - Async / Await
74+ ### Simple Request - Async / Await using curly
7475> this API is experimental and is subject to changes without a major version bump
7576
7677``` javascript
@@ -92,7 +93,21 @@ const { statusCode, data, headers } = await curly.post('http://httpbin.com/post'
9293})
9394```
9495
95- ### Simple Request
96+ JSON POST example:
97+ ``` javascript
98+ const { curly } = require (' node-libcurl' )
99+ const { data } = await curly .post (' http://httpbin.com/post' , {
100+ postFields: JSON .stringify ({ field: ' value' }),
101+ httpHeader: [
102+ ' Content-Type: application/json' ,
103+ ' Accept: application/json'
104+ ],
105+ })
106+
107+ console .log (JSON .parse (data))
108+ ```
109+
110+ ### Simple Request - Using Curl class
96111``` javascript
97112const { Curl } = require (' node-libcurl' );
98113
@@ -115,7 +130,7 @@ curl.on('error', curl.close.bind(curl));
115130curl .perform ();
116131```
117132
118- #### Setting HTTP headers
133+ ### Setting HTTP headers
119134
120135Pass an array of strings specifying headers
121136``` javascript
0 commit comments