I need to get all my alarms form web service in Nativescript. But .map doesn't function. I tried this function. In Angular 5 works good, but in Nativescript show this error:
[ts] Property 'map' does not exist on type 'Observable'. in this .map((response: Response) => {
I import this: import 'rxjs/add/operator/map'; import { Http, Headers, Response } from '@angular/http';
but nothing happens
My "rxjs": "~6.1.0",
public AlarmsGetAll(): Observable<Alarm[]> {
let headers = new Headers();
headers.append('x-access-token', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyaWQiOnsiVXNlcklEIjoiMzEwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAifSwiaWF0IjoxNTI4ODgzNDU1LCJleHAiOjE1Mjk3NDc0NTV9.qei48rzt1KF9AKIEz8Aq-A8pWkESc1G3jBUfdU27oYE');
return this.http.get(Api.getUrl(Api.URLS.AlarmsGetAll), {
headers: headers
})
.map((response: Response) => {
let res = response.json();
console.log(res)
if (res.StatusCode === 1) {
} else {
return res.StatusDescription.map(alarm => {
//console.log(alarm)
return new Alarm(alarm);
});
}
});
}
Can you ask me any idea, what is the problem?
import
mechanism will be in v7 😉 – Royi Namir