Looking for assistance here. Within the localStorage
, I have an object as shown in the example below. My framework of choice is Angular, and I'm trying to retrieve the value associated with the first linkedinMail
key. Despite my attempts using different approaches, the console output only shows the opening curly brace {
Object stored in localStorage:
{"linkedinMail": "mail.com", "password": "123"}
First approach:
public linkedinEmailBody: any
const emailLoginLinkedin = localStorage.getItem('credsForJetLeadBE')
let [key, value] = Object.entries(emailLoginLinkedin)[0];
this.linkedinEmailBody = value;
console.log(this.linkedinEmailBody) // result: `{`
Second approach:
public linkedinEmailBody: any
const emailLoginLinkedin = localStorage.getItem('credsForJetLeadBE')
const valueEmailLinkedin = Object.values(emailLoginLinkedin)[0];
this.linkedinEmailBody = valueEmailLinkedin
console.log(this.linkedinEmailBody) // result: `{`
Third approach:
public linkedinEmailBody: any
const emailLoginLinkedin = localStorage.getItem('credsForJetLeadBE')
const valueEmailLinkedin = emailLoginLinkedin[Object.keys(emailLoginLinkedin)[0]];
this.linkedinEmailBody = valueEmailLinkedin
console.log(this.linkedinEmailBody) // result: `{`
When employing standard JavaScript, I am able to retrieve the correct value for the linkedinMail
field instead of just the opening brace {
. What could be going wrong in my Angular implementation? Appreciate your help.