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);
}
}
Obserble.throw
is now deprecated in recent versions of RxJs, and people should usethrowError
instead (see @slejnej answer below). – Sartinimport { Observable } from "tns-core-modules/ui/page/page";
instead of theimport { Observable } from 'rxjs';
used in web dev. Is that an error or what is on purpose? – Sartin