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: ..
Category : observable
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" ..
In my web app, I have business logic that needs to validate some inputs before navigation to certain routes can proceed. In angularJS I accomplished this process with a complicated promise algorithm that worked well because you could resolve promises at a distance e.g. You could generate a blocking promise for a specific http request, ..
I fully understand how angular lifecycles work. In my NgOnInit() function, I called my asynchronous data service which returns data from the http module. Then, it sets my class variable equal to the returned data. However, my NgAfterViewInit is not picking up these changes. Can anybody explain to me why and how I can fix ..
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 ..
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) {} ..
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:- ..
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) => ..
I’ve been playing with creating my own observables and want to create an observable that returns the 3 times table starting from 3 indefinitely, one every second. However when I try it with this code it freezes the UI and never completes. Could someone explain why this is happening? I’m still unsure what the subscriber ..
Currently working using Angular and leaflet.js, I came across an issue, here it is : I have a Leaflet Map with a GeoJson layer on it, and I want, when clicking on one of the shapes, to have a popup containing all of the instruments from my server (json-server on Heroku) with the origin matching ..
Recent Comments