When trying to make an http request to an api and then console the result using .subscribe in Angular version 6.2 with Typescript version 2.9, I encountered the error "Property 'subscribe' does not exist on type 'Promise'". Despite making changes based on my research, the issue persists.
Below is a snippet of my AuthService file:
import { Injectable } from '@angular/core'
import { CONFIG } from '../config/config'
import { Http } from '@angular/http'
import 'rxjs/add/operator/toPromise'
@Injectable()
export class AuthService {
constructor(private http: Http) {
}
register(name: String, email: String, password: String) {
this.getConfig()
.subscribe((response => {
console.log(response)
}))
}
getConfig() {
return this.http.post(`${CONFIG.API_URL}/register`, { name: name, email: email, password: password }).toPromise()
}
}