Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

192
Views
ERROR TypeError: no se pueden leer las propiedades de nulo (leyendo 'setItem')
private currentStorage = null; setItem(key: string, value: string) { this.currentStorage.setItem(key, value); }

Cuando ejecuto mi código (el fragmento anterior es el único que contiene el elemento setItem), aparece el siguiente error:

 ERROR TypeError: Cannot read properties of null (reading 'setItem') at SessionService.setItem (session.service.ts:53:23) at authentication.service.ts:58:37 at map.js:7:1 at OperatorSubscriber._next (OperatorSubscriber.js:13:1) at OperatorSubscriber.next (Subscriber.js:31:1) at map.js:7:1 at OperatorSubscriber._next (OperatorSubscriber.js:13:1) at OperatorSubscriber.next (Subscriber.js:31:1) at filter.js:6:50 at OperatorSubscriber._next (OperatorSubscriber.js:13:1)

He intentado muchas formas de definir el currentStorage pero el error es el mismo o, a veces, dice "propiedades de indefinido" en lugar de "propiedades de nulo".

¿Alguien puede explicar lo que está pasando?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

esto fue todo lo que pude proporcionar basado en una pregunta

 setItem(key: string, value: string) { if(this.currentStorage){ this.currentStorage.setItem(key, value); } else{ ... //could do nothing here or create the storage this.currentStorage = ... this.currentStorage.setItem(key, value); } }

pero si está buscando el cambio real necesario para el almacenamiento de sesiones

 setItem(key: string, value: string) : void { sessionStorage.setItem(key, JSON.stringify(value)); } /** get an item from session storage */ getItem(string: key) : any | undefined{ let value = sessionStorage.getItem(key); if(value){ return JSON.parse(value); } return undefined; }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!