-
Notifications
You must be signed in to change notification settings - Fork 7
Examples
Jesse Paris edited this page Jan 26, 2021
·
12 revisions
The following here is some different examples of index.js
files that perform various tasks.
var qrsInteract = require('qrs-interact');
var instance = new qrsInteract("localhost");
instance.Get('user')
.then(function(result)
{
console.log(result.body);
})
.catch(function(error)
{
console.log(error);
});
var qrsInteract = require('qrs-interact');
var instance = new qrsInteract("localhost");
instance.Get('tag')
.then(function(result)
{
result.body.forEach(function(element) {
console.log(element.name)
}, this);
})
.catch(function(error)
{
console.log(error);
});
var qrsInteract = require('qrs-interact');
var instance = new qrsInteract("localhost");
instance.Post(
'tag',
{
id: "2454e69a-d2fe-4d1a-bc64-52c5b4232e87",
name: "testTag",
privileges: null
},
'json'
).then(function (result) {
console.log(result.body);
});
var qrsInteract = require('qrs-interact');
var instance = new qrsInteract("localhost");
instance.Get("user?filter=userDirectory eq 'myUserDirectory'")
.then(function(result)
{
result.body.forEach(function(element) {
console.log(element.name)
}, this);
})
.catch(function(error)
{
console.log(error);
});
var qrsInteract = require('qrs-interact');
var instance = new qrsInteract("localhost");
instance.Post(
'app/9bc937ab-2c73-421f-85b2-e8df144b019d/reload',
'',
'application/json'
).then(function (result) {
console.log(result.body);
});
var qrsInteract = require('qrs-interact');
var fs = require('fs');
var fileName = "someLocationToAnApp";
var instance = new qrsInteract("localhost");
fs.readFile(fileName, (err, data) => {
if (err) {
throw err;
}
instance.Post(
'app/upload?name=' + "someAppName",
data,
'application/vnd.qlik.sense.app'
).then(function (result) {
console.log(result.body);
});
});
var qrsInteract = require('qrs-interact');
var fs = require('fs');
var appID = "someAppID";
var token = "someRandomToken";
var fileName = "exportedApp.qvf";
var instance = new qrsInteract("localhost");
var downloadPath = "";
instance.Post(
'app/' + appID + '/export/' + token,
{},
'json'
).then(function(result) {
console.log(result.body);
downloadPath = result.body["downloadPath"];
}).then(function() {
instance.Get(downloadPath)
.then(function(result) {
console.log(result.statusCode);
fs.writeFile(fileName, result.body, {
flag: 'w'
}, function(err) {
if (err) {
console.log("There was an error.")
return;
}
console.log("Success!");
return;
});
})
.catch(function(error) {
console.log(error);
});
});