When I use the http method to retrieve a single user, the output logged in the console looks like this: this.usersService.getOneUser().subscribe(data => { console.log(data) });
email: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="31444254430371565c50585d1f525e5c">[email protected]</a>"
id: "1"
phoneNumber: "23421234"
userName: "user2"
Now, I need to store these values in a new array object. My attempt is shown below:
this.users = new Array(1).fill({}).map((_, index) => {
return <User>{
userName: this.usersService.getOneUser().subscribe(data => {JSON.stringify(data.userName)})
};
});
I tried converting to JSON format without success. Manually typing in values works for adding a user, but the issue lies in populating it from the data obtained through the http request.
return <User>{
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b4c0d1c7c0f4d9d5ddd89ad7dbd9">[email protected]</a>',
id: '1',
phoneNumber: '12345',
userName: 'user'
};
});
The compiler returns an error stating "userName: Subscription neither type sufficiently overlaps with the other"