LWC Stack is Lightning Web Component tutorial series by Salesforce MVP Kapil Batra. In this series you will find LWC tutorials from beginner to intermediate level.
So if you are working on it or planning to learn LWC then this video series is for you. Let's learn and grow together !
Please check complete code below from LWC Stack EP-18
HTML
1 2 3 4 5 6 7 8 9 10 | <template> <lightning-card title="Ger User Data using Wire" icon-name="utility:user"></lightning-card> <template if:true={user.data}> <div style="padding:10px; background-color:white"> <p>Id : {userId}</p><br /> <p>Name : {name}</p> </div> </template> </template> </template> |
JS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | import { LightningElement,wire } from 'lwc'; import {getRecord, getFieldValue} from 'lightning/uiRecordApi'; import Id from '@salesforce/user/Id'; import NAME_FIELD from '@salesforce/schema/User.Name'; const fields = [NAME_FIELD]; export default class GetUserDetails extends LightningElement { userId = Id; @wire(getRecord,{recordId:'$userId',fields}) user; get name(){ return getFieldValue(this.user.data, NAME_FIELD); } } |
Checkout complete tutorial below
0 Comments