Is there any way to get Object label from API Name? I tried Below, but it gives API Name Only
import objectName from '@salesforce/schema/object';
Salesforce should provide easy way to get the standard object labels without necessarily using ui api.
With UI api one can get the label as below
<template>
<lightning-card title={objectInfo.data.label} icon-name="standard:account">
</lightning-card>
</template>
JS file
import { LightningElement, wire, api, track } from 'lwc';
import { getObjectInfo } from 'lightning/uiObjectInfoApi';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';
export default class ObjectLabel extends LightningElement {
@api objectApiName;
@track objectInfo;
@wire(getObjectInfo, { objectApiName: ACCOUNT_OBJECT })
objectInfo;
}
The other alternative would be to write an apex class that can return the object label taking object api name as parameter and then use @wire service to display on lwc frontend .