Category : observable

I need to call this api: insertATT(id: string, name: string, file: File): Observable<Object[]> { const httpOptions = { } const formData = new FormData(); formData.append(‘id’, id); if (Utility.isNotNull(file[0])) { formData.append(‘n1’, name); formData.append(‘f1’, file); } return this.http.post(‘insert’, formData, httpOptions).pipe(map( (response: Object[]) => {console.log(response); return response }, ), catchError((error) => { return throwError(error); })); } The call: ..

Read more

I have these 3 Observables from 3 different Services (3 API calls): this.gs.getLocationName().subscribe((loc) => this.locationName = loc); this.gs.getLocationInfo(this.locationName).subscribe((data) => { this.lat = data.results.geometry.location.lat; this.lon = data.results.geometry.location.lng; }); this.ws.getWeatherByCoordinates(this.lat, this.lon).subscribe((data) => …); As you can see it depends on the previous Observable, so I want to run them one by one. I know how to "combine" ..

Read more

This is my first Angular project and I can’t assign data retrieved from the http.get().subscribe(…) method to my component class variable. My component: … export class LeafletMapComponent implements OnInit, AfterViewInit { allData constructor(private ps: PeopleService, private NgZone: NgZone) {} ngAfterViewInit(): void { console.log(this.allData) **DOESN’T WORK** } ngOnInit(): void { this.ps.httpGetData().subscribe( data => { this.data= data ..

Read more

this is my first Stack Overflow post so bare with me if I formatted anything incorrectly. This is my first Angular project and I can’t assign data retrieved from the http.get().subscribe(…) method to my component class variable. My component: … export class LeafletMapComponent implements OnInit, AfterViewInit { data constructor(private ps: PeopleService, private NgZone: NgZone) {} ..

Read more

Currently I am making 3 different API calls which are below like this:- //API Call1 getUserById(id){ return this.http .get(`${environment.userAPI}/user/${Id}`, { headers: this.headers }) .pipe( catchError(err => { return throwError(this.errorHandler.handleError(err)); }), ); } //API Call 2:- getTeamById(id){ return this.http .get(`${environment.TEAM_API}/team/${Id}`, { headers: this.headers }) .pipe( catchError(err => { return throwError(this.errorHandler.handleError(err)); }), ); }; ////API Call 3:- ..

Read more

hi i have two guard in my routing. my first guard is like below code canActivate( route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree { const token = localStorage.getItem(‘token’); if (token) { if (this.authStore.getUserValue()) { this.user = this.authStore.getUserValue(); return true; } else { return new Promise((resolve, reject) => ..

Read more