import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable, of } from 'rxjs';
import { catchError } from 'rxjs/operators';

import { FullnodeService} from './fullnode.service';

@Injectable({
	providedIn: 'root'
})

export class NodeResolverService  {
	constructor(private fullnode: FullnodeService) {}

	resolve(route: ActivatedRouteSnapshot): Observable<any> {
		//console.log('Called getAddr in resolver...', route);
		return this.fullnode.getAddr().pipe(
			catchError(() => {
				return of('No data');
			})
		);
	}
}
