Questions tagged observable

Explore the latest questions and answers asked by our top developers.

Angular: Observable with subscribe returns error 200 OK as the response is not JSON

I am developing a front-end web application using Angular 11. This application uses several services which return data in JSON format. I use the async / await javascript constructs and the Observables to get the answers from these services. This is an example my call: let myResponse = await this.myService(this.myData); myResponse.subscribe( res => { console.log("Res: […]

Populate dropdown from observable

I try to fill an array with values provinding from one service. The array must fill a dropdown. I follow this post. The array is defined like this : dropdownList: Array<{id: number, description: string}>; The service method’s is : async loadFoodTypes(){ const api: string = environment.apiAddress + ‘FoodType’; await this.httpClient.get<FoodType[]>(api) .pipe() .toPromise() .then((response: FoodType[]) => […]

By Paintbox
Published
Categorized as angular, javascript, observable Tagged , ,

Angular not displaying streamed data in UI using observable

I have python server which does server side streaming, i could see the request is successful, in browser i could see the data coming as stream for 10s. But in network tab response preview is coming only after all the data s being received. I have used observable to handle the response. The success call […]

By user2900572
Published
Categorized as angular, observable, streaming Tagged , ,

Observable response in tap different from response in map

I have difficulties with a httpClient request in an angular project, maybe you guys can help me out: private request<T>( method: RequestMethod, endpoint: string, options?: RequestOptions ): Observable<T> { return this.httpClient.request(method, `${this.baseUrl}${endpoint}`, options).pipe( tap((response) => { const processedResponse = JSON.parse(JSON.stringify(response)); // here the log shows values as given in the http response from server console.log(processedResponse); […]

By Magelan
Published
Categorized as angular, angular-httpclient, observable Tagged , ,

Angular RxJS function not calling HTTP request

I have an angular store where I try to call some code, that is supposed to perform an HTTP request in an interval. This is supposed to call and HTTP endpoint and update the state of an angular store every 5 seconds. All my console.log statements are called correctly in the interval, but in the […]

By Dedi
Published
Categorized as angular, observable, rxjs, typescript Tagged , , ,

Get object from angular observable ngrx/store

I have a problem getting an object from the @ngrx/store. This code worked fine for a long time, but now it seems to be broken and I don’t know why. The object to store has this structure: export class UserInfo { user: string; token: string; permissions: string[]; } This function saves my object to the […]

By ochs tobi
Published
Categorized as angular, ngrx-store, observable Tagged , ,

angular how to get array of nested object from two tables one-to-many related

Hi everybody I have 2 mysql tables: itemsClass which contains a list of possible classes, and itemType which refers to itemClass and contains type values of a particular class. I’m trying to build a service which returns an Observable<Item[]>, combining two http.get Observables, suiting this interface: interface Item{ itemcClassId:any; //class.id itemClassName:any; //class.name itemTypeValue?:any; //if the […]

Angular rxjs Subject : subscribing to a subject after emitting values

I have read an article in which it states that in which it says, if you subscribe to subject when the event has been already emitted You would lose the emitted value. his demonstrated example is below. let subject: Subject<string> = new Subject(); subject.next(‘test’); subject.subscribe((event) => { console.log(event); }); But ,I have a similar approach […]

By Aslam Jiffry
Published
Categorized as angular, javascript, observable, rxjs, subject Tagged , , , ,

Error in a Observable subscription using reduce operator

I have the following rxjs observable: export interface SubExperimentData { experimentId: number; name: string; subexperiment: { name: String avg: number; max: number; }[]; } What i wanna do now is to get all subexperiment of a specific experiment. I use the following code to get all subexperimentdata from one experiment. choosedExperiment is containing the selected […]

By cowboy192
Published
Categorized as angular, observable, rxjs Tagged , ,

Cannot get response from HttpClient

I have been trying to handle an error response from my API. What I’m trying to get: What I’m actually getting: my service.ts: import { HttpClient, HttpErrorResponse } from ‘@angular/common/http’; import { Injectable } from ‘@angular/core’; import { environment } from ‘src/environments/environment’; import { map, catchError } from ‘rxjs/operators’; private url = environment.urlServer; constructor( private […]

1 2 3 88

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq