If you are using NodeJS, here is an example of performing an API request into the ionlake platform.
var https = require('https');
var http = require('http');
// run the app
function run() {
// the data for the post
const postData ="{'action': '<your action>'}";
// the options for the post
const options = {
hostname: "dart.ionlake.com",
port: "443",
path: "/dart/core",
method: 'POST',
headers: {
"Content-Type": "application/json",
"Content-Length": Buffer.byteLength(postData),
"X-Apikey": "7d0XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"X-SecretKey": "<SECRET KEY>"
}
};
// the function that does the post
function processRequest() {
var protocol = https;
var postReq = protocol.request(options, (res) => {
console.log("STATUS: " + res.statusCode);
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('Response: ' + chunk);
});
res.on('end', () => {
console.log('No more data in response.');
});
});
postReq.write(postData);
postReq.end();
}
// display a nice message and indicate whith environment we are processing
console.log("Running Request");
// go
processRequest();
}
Comments
0 comments
Please sign in to leave a comment.