@hivegpt/hiveai-angular 0.0.72 → 0.0.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1284,26 +1284,26 @@
1284
1284
  console.log('Selected agent:', agent);
1285
1285
  // You can handle selected agents here, e.g., save them to a variable or send to an API
1286
1286
  };
1287
+ ChatDrawerComponent.prototype.fetchAgents_http = function () {
1288
+ var headers = new http.HttpHeaders({
1289
+ 'Content-Type': 'application/json',
1290
+ 'x-api-key': this.apiKey,
1291
+ });
1292
+ var url = this.environment.AGENTS_API + "/CoPilot/" + this.botId + "/public-agents";
1293
+ return this.http.post(url, {}, { headers: headers }).pipe(operators.switchMap(function (res) {
1294
+ return rxjs.of(res);
1295
+ }), operators.catchError(function (error) {
1296
+ return rxjs.of(null);
1297
+ }));
1298
+ };
1287
1299
  ChatDrawerComponent.prototype.fetchAgents = function () {
1288
1300
  var _this = this;
1289
- var url = this.environment.AGENTS_API + "/CoPilot/" + this.botId + "/public-agents";
1290
- fetch(url, {
1291
- method: 'GET',
1292
- headers: {
1293
- 'Content-Type': 'application/json',
1294
- 'x-api-key': this.apiKey,
1295
- }
1296
- })
1297
- .then(function (response) { return response.json(); })
1298
- .then(function (data) {
1301
+ this.fetchAgents_http()
1302
+ .subscribe(function (data) {
1299
1303
  if (data) {
1300
- _this.agents = data;
1301
- _this.agents.forEach(function (element) {
1302
- element.selected = false;
1303
- });
1304
+ _this.agents = data.map(function (agent) { return (Object.assign(Object.assign({}, agent), { selected: false })); });
1304
1305
  }
1305
- })
1306
- .catch(function (error) {
1306
+ }, function (error) {
1307
1307
  console.error('Error:', error);
1308
1308
  });
1309
1309
  };