⚠️ MOVED TO OpenFn/adaptors! ⚠️
N.B.: New versions are available at: https://github.com/OpenFn/adaptors/tree/main/packages/http
Language Pack for building expressions and operations to make HTTP calls.
{
"username": "[email protected]",
"password": "supersecret",
"baseUrl": "https://instance_name.surveycto.com",
}
This helper function allows the use of a get method to fetch data. You can specify a query string for filter.
get(
'/myendpoint',
{
query: { foo: 'bar', a: 1 },
headers: { 'content-type': 'application/json' },
authentication: { username: 'taylor', password: 'somethingsecret' },
},
state => {
return state;
}
);
Send some data to an existing endpoint.
post('/endpoint', {
body: state => {
return {
field_1: 'some_data',
field_2: 'some_more_data',
field_id: dataValue('Some.Json.Object.Id')(state),
};
},
headers: {
Authorization: 'AUTH_KEY',
'Content-Type': 'application/json',
},
});
put(
'/myendpoint',
{
body: { firstname: 'taylor', lastname: 'downs' },
headers: { 'content-type': 'application/json' },
authentication: { username: 'user', password: 'pass' },
},
state => {
return state;
}
);
patch(
'/myendpoint',
{
body: { firstname: 'taylor', lastname: 'downs' },
headers: { 'content-type': 'application/json' },
authentication: { username: 'user', password: 'pass' },
},
state => {
return state;
}
);
del(
'/myendpoint',
{
query: { id: 'someId' },
headers: { 'content-type': 'application/json' },
authentication: { username: 'user', password: 'pass' },
},
state => {
return state;
}
);
This function allows you to parse some xml data. A callback function can be use to store in a table.
parseXML(body, function ($) {
return $('table[class=your_table]').parsetable(true, true, true);
});
parseCSV('/home/user/someData.csv', {
quoteChar: '"',
header: false,
});
parseCSV('/home/taylor/PatientsJan2009.csv', {
quoteChar: '"',
header: false,
columns: true,
skip_empty_lines: true,
trim: true,
bom: true,
});
Clone the repo, run npm install
.
Run tests using npm run test
or npm run test:watch
Build the project using make
.
To build the docs for this repo, run ./node_modules/.bin/jsdoc --readme ./README.md ./lib -d docs
.