Iam learning nativescript+angular for developing android and ios apps.Iam working and learning basic services of nativescript+angular.In the post method of the my project i have the error 'property 'throw' does not exist on type 'typeof Observable'. My Code is:
import { User } from "./user";
import { Config } from "../config";
import { Injectable } from "@angular/core";
import { Observable } from "tns-core-modules/ui/page/page";
@Injectable()
export class UserService {
constructor(private http: Http) { }
register(user: User) {
let headers = new Headers();
headers.append("Content-Type", "application/json");
return this.http.post(
Config.apiUrl + "Users",
JSON.stringify({
Username: user.email,
Email: user.email,
Password: user.password
}),
{ headers: headers }
)
.catch(this.handleErrors);
}
handleErrors(error:Response)
{
console.log(JSON.stringify(error.json()));
return Observable.throw(error);
}
}
Observable.throw is now deprecated. You have to use this instead:
import { throwError } from 'rxjs';
then replace your Observable.throw
with throwError("Your error")
.
Your subscriber to observable will picked it up in the same way it did in the past.
Check here @ #287
Observable.throw and throwError("Your error") are now deprecated. Now, you should use a factory directly as throwError(() => new Error('Your error'))
Check here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With