Questions tagged undefined

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

Lost data stored in localStorage issue

I have a token stored in localStorage, I have also a method that verifies if the token is correct or not, as you can see in this code: let token = localStorage.getItem(‘token’); console.log(token); if ( !token ) { return null; } const parts = token.split(‘.’); if ( parts.length !== 3 ) { throw new Error(‘error’); […]

Angular 11 You provided ‘undefined’ where a stream was expected

I’m not getting error message and error code when it comes from server side in angular. below code I’m using for all service. I’m using angular 11 and in the below code getting error postEvidenceFiles(path: string, data: any, _arguments?: HttpParams) { let headers = new HttpHeaders(); headers = headers.set( ‘Authorization’, `Bearer ${this.AuthStorageService.getToken()}`, ); headers.append(‘Accept’, ‘application/json, […]

By John Mark
Published
Categorized as angular, angular-services, service, undefined Tagged , , ,

Interpolation error on Angular result undefined

I have an interpolation problem i need to do something that comes from an api like this, {columna1=6.022, columna2=0.0, columna3=3.14…..,columnaN=5.55 } Sometimes there’s only one ‘columna’, sometimes came 30 ‘columna’ so I need to interpolate them easily, and for that I’m doing this in html file <ng-container *ngFor="let numero of arregCols"> <p>columna{{numero}} = {{ columna[numero] […]

Angular Typescript object property is clearly not undefined but property is

Im having a rather ridicolous problem. An object from an subscribed observable has clearly data in it, while printing it to console, but in actual code typescript says its undefined. See for yourself: initData(): void { this.backendService.getData().subscribe((depotDays: DepotDayAcc[]) => { console.log(depotDays) console.log(depotDays[0]) console.log(depotDays[0].investment) console.log(depotDays[0]["day"]) console.log(‘depotDays[0] == undefined’, depotDays[0] == undefined) console.log(‘depotDays[0].investment == undefined’, depotDays[0].investment == […]

By Plagueis
Published
Categorized as angular, typescript, undefined Tagged , ,

Angular – Browser not recognizing new classes, treating them as "undefined"

This is the weirdest thing i’ve ever seen. I have a .ts file named "MensajeBloqueo" which contains this class: export class MensajeBloqueo { idLegacy: string; idBloqueo: string; idSegmento: string; idEtapa: string; idEstado: string; mensaje: string; } This is a new class that i made today, i created it the same way i create any other […]

By FranciscoFJM
Published
Categorized as angular, browser, class, typescript, undefined Tagged , , , ,

How to use ‘this’ in Promise?

I am trying to make an http request inside a Promise function. I get the this.http.post is undefined error… I know that I somehow have to access this some other way but I did not understand how to do it :/ Anyone willing to help me out? Thanks!! doUpload(files: Array<File>): Promise<Array<UploadResult>> { console.log(files); return new […]

By papafredo6
Published
Categorized as angular, httpclient, post, typescript, undefined Tagged , , , ,

API Data undefined when used in the component

i have this service to get data from the api and save it into arrays afterwards: export class DataService { constructor(private http: HttpClient) { } readonly baseURL = "https://localhost:44302/api"; books: Book[]; users: User[]; cards: Card[]; postId: number; httpOptions = { headers: new HttpHeaders({ ‘Content-Type’: ‘application/json’ }) } getBooks() { return this.http.get(this.baseURL + ‘/books’); } getCards() […]

By manu kanu
Published
Categorized as angular, api, get, typescript, undefined Tagged , , , ,

TypeError: Cannot read properties of undefined (reading ‘fan’)

This is a parent component template file. It is not giving any problem app.component.html <div> <input type="text" [(ngModel)]="electronics.light" name="light" placeholder="light"> <input type="text" [(ngModel)]="electronics.fan" name="fan" placeholder="fan"> </div> <button (click)="display();">Display</button> <div *ngIf="flag"> <app-electronics-layout [images]="images" [electronicsObj]="electronics"></app-electronics-layout> </div> This is some part of the child component ts file where the display1() method is called on button click to verify […]

NGX build plus-Cannot read properties of undefined (reading ‘push’)

I’ve been trying to build a chatbot microfrontend angular application using angular elements and ngx build plus. I just followed the documents found online (https://dzone.com/articles/scaling-micro-frontends-using-angular-elements). Just to give some context, I have an empty array called "messages" to store messages into a class and it will be used to push to frontend and also send […]

Argument of type ‘boolean | undefined’ is not assignable to parameter of type ‘boolean’

I tried to insert an Auth System to the Angular App. (This one. After finishing everything, I got for this code: private userCurrentState = new BehaviorSubject<boolean>(this.tokenAuthService.isSignedin()); this error message Argument of type ‘boolean | undefined’ is not assignable to parameter of type ‘boolean’. TokenAuthService code getJwtToken(){ return localStorage.getItem(‘auth_token’); } validateToken(){ const token = this.getJwtToken(); if(token){ […]

By Philipp
Published
Categorized as angular, rxjs, typescript, undefined Tagged , , ,
1 2 3 7

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