Reputation: 17
I developed an application in OFFICEjs. It is all working in LOCALHOST. Last week the program worked perfectly sending data to the server and getting back the data from it. Monday I started the program and got the following Error:
XHR Error.
During the weekend I didnt touch the code so I can not understand what happened in between that now no https requests are being sent to the server neither POST nor GET.
When I put the URL in the Browser I get the correct answer from the server, so the server is working correctly. The only matter is with the client side, the https request is not even fired any more! what could have been happened during the weekend that caused communication problems in the program.. Please help as I spent 2 days so far on trying to find the problem without success. You should notice that even now or at any time till now, if you enter the same URL in the browser you get the data back in the browser without problem.
Now I noticed something new. I deleted the call of the function https_Last_Order_Number() and instead did an https regular call inside the send function. The result is nothing. I dont get any error but also the request is not being fired at all! It is the same https call I used to do before and that worked but now doesnt fire at all
async https_Last_Order_Number(){return new Promise((resolve, reject) => {
const options = {
hostname: 'localhost',
port: 8888,
path: '/getLastIdOrder',
method: 'GET'
}
const req = https.request(options,
(res) => {
let body = '';
res.on('data', (chunk) => (body += chunk.toString()));
res.on('error', reject);
res.on('end', () => {
if (res.statusCode >= 200 && res.statusCode <= 299) {
resolve({statusCode: res.statusCode, headers: res.headers, body: body});
} else {
reject('Request failed. status: ' + res.statusCode + ', body: ' + body);
}
});
});
req.on('error', reject);
req.end();
});
}
async send() {
try {
await Excel.run( async context => {
var currentWorksheet = context.workbook.worksheets.getActiveWorksheet();
var range3 = currentWorksheet.getRange("H14");
var tmpAcc = ""; //hold current acc to check.
var check = 1; //suppose no problem at begining.
var numAccRows = 0;
//var numDuplicate=0;
//const rankingRange = this.table.columns.getItem("Quantity").getDataBodyRange().load("values");
let Last_Order_number // Last order Id, returned as String.
let Last_Order_num // Last order Id, as INT.
await this.https_Last_Order_Number().then(function(results){
Last_Order_number = results['body']
Last_Order_num = parseInt(Last_Order_number) + 1
return context.sync()
.then(function () {
for (let i = 0; i < 50; i++) { // for each acc, check for duplicate.
if (accountRange.values[i][0] === "" || check == 0){
break;
}
numAccRows = numAccRows + 1; // count number of rows.
tmpAcc = accountRange.values[i][0];
for (let j = i+1; j < 50; j++){
if (accountRange.values[j][0] === "" ){ //if row empty, means this is no more accounts in this column, thus break.
break;
}
if (tmpAcc == accountRange.values[j][0]){ //if the acc is duplicated, break.
check=0;
//numDuplicate=numDuplicate+1;
//let tmpCell="k"+j;
//let range4 = currentWorksheet.getRange(tmpCell);
//range4.values = [[tmpAcc]];
break;
}
}
}
}
}
});
}).catch(err => {
range3.values =[[900]]
OfficeHelpers.UI.notify(err);
OfficeHelpers.Utilities.log(err);
});
});
} catch (error) {
OfficeHelpers.UI.notify(error);
OfficeHelpers.Utilities.log(error);
}
}
Upvotes: 0
Views: 150
Reputation: 17
the problem was that the certificate simply expired...it was for one month only
Upvotes: 1