Search code examples
angulartypescriptrxjsangularfire2angularfire

Property 'pipe' does not exist on type 'void' Angular 6


I don't understand the cause of the problem. my code from Service File and i get Error

  1. Property 'pipe' does not exist on type 'void'.
  2. Property '$key' does not exist on type '{}'.

enter image description here

import { Injectable } from '@angular/core';
import { AngularFireDatabase, AngularFireList } from '@angular/fire/database';
import { switchMap } from 'rxjs/operators';
import { Observable } from 'rxjs';
@Injectable({
  providedIn: 'root'
})
export class CoursesService {

  constructor(private af: AngularFireDatabase) { }

  findAllCourses(): AngularFireList<any> {
    return this.af.list('courses');
  }

  findCourseDtl(coursUrl:string){
   this.af.list('courses', ref => ref.orderByChild('url').equalTo(coursUrl)).valueChanges()
  }

  findLessonsForCours(coursUrl:string): Observable<any>{
    return this.findCourseDtl(coursUrl)
   .pipe(switchMap(course => this.af.list('lessonsPerCourse/'+ course.$key ).valueChanges()));


}

}

Solution

  • You didn't return any value in the findCourseDtl function.

    This may be what you intended:

    findCourseDtl(coursUrl:string){
      return this.af.list('courses', ref => ref.orderByChild('url').equalTo(coursUrl)).valueChanges()
    }