hey guys,
I there any reason why my previously working code (without await
) now stopped working? I don’t see any messages popping up anymore in mongo for the code in the async function?
async function reloadAppAndReplaceScriptviaEngine(appId, scriptReplace, generationUserId) {
const config = {..}
try {
var qix = await enigma.getService('qix', config);
var call = {};
call.action = 'Connect to Qlik Sense Engine API';
REST_Log(call, generationUserId);
REST_Log
import { Mongo } from 'meteor/mongo';
export const APILogs = new Mongo.Collection('apiLogs');
export function REST_Log(call, userId = 'Not defined') {
call.createDate = new Date();
call.generationUserId = userId;
if (Meteor.isServer) {
**APILogs.rawCollection().insert(call);**
} else {
APILogs.insert(call);
}
return;
}
Strange, if I put a new `var call = {}’ before I try to do my logging, it suddenly works again like this
//get the script
console.log('get script');
var script = await qix.app.getScript();
**var call = {};**
call.action = 'Get data load script';
call.url = gitHubLinks.getScript;
call.request = 'We extracted the following load script from the app';
call.response = script;
REST_Log(call, generationUserId);
//set the new script
console.log('set script');
**var call = {};**
call.response = await qix.app.setScript(replaceScript(script)) //we now just include the old script in this app
call.action = 'Insert customer specific data load script for its database';
call.url = gitHubLinks.setScript;
call.request = 'The script of the app has been replaced with a customer specific one. Normally you would replace the database connection for each customer. Or you can insert a customer specific script to enable customization per customer. ';
REST_Log(call, generationUserId);
like this