Below is a snippet of code from my service file:
import { Injectable } from '@angular/core';
import { Http, Response } from "@angular/http";
import {map, catchError} from 'rxjs/operators';
import { Observable } from "../../node_modules/rxjs";
@Injectable({
providedIn: 'root'
})
export class SessionService {
BASE_URL = "http://localhost:3000"
constructor(private http: Http) { }
handleError(e) {
return Observable.throw(e.json().message);
}
signup(formSignup) {
return this.http.post(`${this.BASE_URL}/api/signup`, formSignup)
.pipe(map(res => res.json())),
catchError(this.handleError);
}
In the following code block, we are encountering an error related to the subscribe method:
import { Component, OnInit } from '@angular/core';
import { SessionService } from '../../services/session.service';
import { Router } from '@angular/router'
@Component({
selector: 'app-signup-form',
templateUrl: './signup-form.component.html',
styleUrls: ['./signup-form.component.css']
})
export class SignupFormComponent implements OnInit {
constructor(
private sessionService:SessionService,
private router:Router) { }
ngOnInit() {
}
sendSignupForm(myForm){
this.sessionService.signup(myForm.value)
.subscribe(()=> this.router.navigate(['private']))
}
}
I am facing an issue with subscribing to my API call in the service file. The error message being displayed is as follows:
The
OperatorFunction<{}, {}>>' typesubscribe' property does not exist in the
I am seeking assistance to resolve this error. Any suggestions or help would be greatly appreciated. Thank you.