I have a nested Object which will contain information like userId, token, name, email, phone, company name etc till the user logouts. I need to use certain values of the object when calling an API.
Is there a way to globally set and get the values of the object in each of my component. Currently what I have done is I have setter and getter and I set and get the values individually but it's very time consuming and since I get the values seperately I have to form the Object again in each of the component. Current approach :
Create a service class and create two functions.
setEmailData(info) { this.info = info; } getEmailData() { const temp = this.info; // this.clearData(); return temp; }
I do this for atleast 10 values. Is there a way I can create and set and fetch the values of an object directly? My actual object looks something like this
userData = {
border: {
border: '',
visible: true
},
header: {
title: '',
visible: true
},
isLoggedIn: false,
uid: '',
uid_loader: false,
user: {
UserID: '',
company: 'dev',
emaild: '',
lastname: '',
name: '',
phone: '',
token: '',
url: ''
}
};