Skip to content

Commit 69c0888

Browse files
committed
check for undefined result
1 parent d03467a commit 69c0888

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

OpenFlowNodeRED/src/node-red-contrib-openflow-storage.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ export class noderedcontribopenflowstorage {
366366
Logger.instanse.silly("noderedcontribopenflowstorage::_getnpmrc");
367367
if (WebSocketClient.instance != null && WebSocketClient.instance.isConnected()) {
368368
const array = await NoderedUtil.Query("nodered", { _type: "npmrc", nodered_id: Config.nodered_id }, null, null, 1, 0, null, null, null, 1);
369-
if (array.length === 0) { return null; }
369+
if (NoderedUtil.IsNullUndefinded(array) || array.length === 0) { return null; }
370370
try {
371371
this.npmrc = array[0];
372372
} catch (error) {
@@ -423,7 +423,7 @@ export class noderedcontribopenflowstorage {
423423
Logger.instanse.silly("noderedcontribopenflowstorage::_getFlows");
424424
if (WebSocketClient.instance.isConnected()) {
425425
const array = await NoderedUtil.Query("nodered", { _type: "flow", nodered_id: Config.nodered_id }, null, null, 1, 0, null, null, null, 1);
426-
if (array.length === 0) { return []; }
426+
if (NoderedUtil.IsNullUndefinded(array) || array.length === 0) { return []; }
427427
try {
428428
this._flows = JSON.parse(array[0].flows);
429429
result = this._flows;
@@ -499,7 +499,7 @@ export class noderedcontribopenflowstorage {
499499
cred = [];
500500
}
501501
const filename: string = Config.nodered_id + "_credentials";
502-
if (cred.length == 0) {
502+
if (NoderedUtil.IsNullUndefinded(cred) || cred.length == 0) {
503503
let json = await this.backupStore.get<string>(filename, null);
504504
if (!NoderedUtil.IsNullEmpty(json)) {
505505
json = noderedcontribopenflowstorage.decrypt(json);
@@ -991,7 +991,7 @@ export class noderedcontribopenflowstorage {
991991
item = [];
992992
}
993993
const filename: string = Config.nodered_id + "_sessions";
994-
if (item == null || item.length == 0) {
994+
if (NoderedUtil.IsNullUndefinded(item) || item.length == 0) {
995995
const json = await this.backupStore.get<string>(filename, null);
996996
if (!NoderedUtil.IsNullEmpty(json)) {
997997
item = JSON.parse(json);

0 commit comments

Comments
 (0)