BoxfishCurl.js
Installation
npm install boxfishcurl
Using simple Request
Usage
curl.get('http://google.com').then([Function], [Function]);
curl.post('http://your-post-url', params).then([Function], [Function]);
curl.put('http://your-PUT-url', params).then([Function], [Function]);
curl.delete('http://your-DELETE-url', params).then([Function], [Function]);
default properties
you can set any request options here, including any header you may need.
curl.init({ headers: { 'Content-Type' : 'application/json' } });
Using HTTP and HTTPS modules
Usage
Param |
type |
Required |
Default |
host |
string |
true |
- |
path |
string |
true |
- |
port |
string |
|
80 |
method |
string |
|
'GET' |
headers |
object |
|
- |
data |
string |
|
'application/x-www-form-urlencoded' |
curl
.req({
host : 'boxfish.com',
path : '/',
headers : { 'Content-Type': 'application/json' },
method : 'POST',
data : {
field : 'this can be any JSON',
used : 'this will be sent in the request body',
required : false
}
}).then(function(response) {
}, function(err) {
});
Run test
npm test