File size: 975 Bytes
08eaca3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
interface DecisionTree {
startNode: string;
nodes: { [key: string]: Node };
}
interface Node {
type: string;
text: string;
answers?: Answer[];
next?: string;
}
interface Answer {
text: string;
next: string;
}
@Injectable({
providedIn: 'root'
})
export class CouchdbService {
private dbUrl = 'https://192.168.57.185:5984/decison-tree-db/decisiontree_2';
private username = 'd_couchdb'; // Replace with your CouchDB username
private password = 'Welcome#2'; // Replace with your CouchDB password
constructor(private http: HttpClient) { }
getDecisionTree(): Observable<{ data: DecisionTree }> {
const headers = new HttpHeaders({
'Authorization': 'Basic ' + btoa(this.username + ':' + this.password)
});
return this.http.get<{ data: DecisionTree }>(this.dbUrl, { headers });
}
}
|