Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fjage.js): changing agentsForService to also reject promise if n…
Browse files Browse the repository at this point in the history
…o response
notthetup committed Jan 23, 2024
1 parent 417b747 commit 17ae145
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions gateways/js/src/fjage.js
Original file line number Diff line number Diff line change
@@ -729,7 +729,11 @@ export class Gateway {
async agentForService(service) {
let rq = { action: 'agentForService', service: service };
let rsp = await this._msgTxRx(rq);
if (!rsp || !rsp.agentID) return;
if (!rsp) {
if (this._returnNullOnError) return null;
else throw new Error('Unable to get agent for service');
}
if (!rsp.agentID) return null;
return new AgentID(rsp.agentID, false, this);
}

@@ -743,7 +747,11 @@ export class Gateway {
let rq = { action: 'agentsForService', service: service };
let rsp = await this._msgTxRx(rq);
let aids = [];
if (!rsp || !Array.isArray(rsp.agentIDs)) return aids;
if (!rsp) {
if (this._returnNullOnError) return aids;
else throw new Error('Unable to get agents for service');
}
if (!Array.isArray(rsp.agentIDs)) return aids;
for (var i = 0; i < rsp.agentIDs.length; i++)
aids.push(new AgentID(rsp.agentIDs[i], false, this));
return aids;

0 comments on commit 17ae145

Please sign in to comment.