Skip to main content

http@4.2.3

Adaptor

Adaptor.execute

Kind: static class of Adaptor

new exports.execute(operations)

Execute a sequence of operations. Wraps language-common/execute, and prepends initial state for http.

ParamTypeDescription
operationsOperationsOperations to be performed.

Example

execute(
create('foo'),
delete('bar')
)(state)

Adaptor.get

Kind: static class of Adaptor
Access: public

new exports.get(path, params, callback)

Make a GET request

ParamTypeDescription
pathstringPath to resource
paramsobjectQuery, Headers and Authentication parameters
callbackfunction(Optional) Callback function

Example

get('/myEndpoint', {
query: {foo: 'bar', a: 1},
headers: {'content-type': 'application/json'},
authentication: {username: 'user', password: 'pass'}
})

Adaptor.post

Kind: static class of Adaptor
Access: public

new exports.post(path, params, callback)

Make a POST request

ParamTypeDescription
pathstringPath to resource
paramsobjectBody, Query, Headers and Authentication parameters
callbackfunction(Optional) Callback function

Example

post('/myEndpoint', {
body: {'foo': 'bar'},
headers: {'content-type': 'application/json'},
authentication: {username: 'user', password: 'pass'}
})

Adaptor.put

Kind: static class of Adaptor
Access: public

new exports.put(path, params, callback)

Make a PUT request

ParamTypeDescription
pathstringPath to resource
paramsobjectBody, Query, Headers and Auth parameters
callbackfunction(Optional) Callback function

Example

put('/myEndpoint', {
body: {'foo': 'bar'},
headers: {'content-type': 'application/json'},
authentication: {username: 'user', password: 'pass'}
})

Adaptor.patch

Kind: static class of Adaptor
Access: public

new exports.patch(path, params, callback)

Make a PATCH request

ParamTypeDescription
pathstringPath to resource
paramsobjectBody, Query, Headers and Auth parameters
callbackfunction(Optional) Callback function

Example

patch('/myEndpoint', {
body: {'foo': 'bar'},
headers: {'content-type': 'application/json'},
authentication: {username: 'user', password: 'pass'}
})

Adaptor.del

Kind: static class of Adaptor
Access: public

new exports.del(path, params, callback)

Make a DELETE request

ParamTypeDescription
pathstringPath to resource
paramsobjectBody, Query, Headers and Auth parameters
callbackfunction(Optional) Callback function

Example

del(`/myendpoint/${state => state.data.id}`, {
headers: {'content-type': 'application/json'}
})

Adaptor.parseXML

Kind: static class of Adaptor
Access: public

new exports.parseXML(body, script)

Parse XML with the Cheerio parser

ParamTypeDescription
bodyStringdata string to be parsed
scriptfunctionscript for extracting data

Example

parseXML(body, function($){
return $("table[class=your_table]").parsetable(true, true, true);
})

Adaptor.parseCSV

Kind: static class of Adaptor
Access: public

new exports.parseCSV(target, config)

CSV-Parse for CSV conversion to JSON

ParamTypeDescription
targetStringstring or local file with CSV data
configObjectcsv-parse config object

Example

parseCSV("/home/user/someData.csv", {
quoteChar: '"',
header: false,
});

Adaptor.request

Kind: static class of Adaptor

new exports.request(params)

Make a request using the 'request' node module. This module is deprecated.

ParamTypeDescription
paramsobjectQuery, Headers and Authentication parameters

Example

request(params);