Using lightning-record-view-from in LWC

This blog post is the next post in the series of posts that are targeted towards understanding the tags in LDS.

When you want to fetch a record in LWC without using JavaScript and Apex code then we will be using lightning-record-view-form.

This tag has to be provided object-api-name and record-id attributes to fetch the record and display it back to the users.

Here is the snippet of the code.

<template>
	<lightning-record-view-form 
    object-api-name="Account" 
    record-id={recordId}>
    <lightning-output-field field-nam="Name"></lightning-output-field>    
    <lightning-output-field field-nam="Industry"></lightning-output-field>    
	<lightning-output-field field-nam="Rating"></lightning-output-field>    
    </lightning-record-view-form>
</template>
Using lightning-record-edit-from in LWC
import { LightningElement, api } from 'lwc';

export default class HelloWorld extends LightningElement {
    @api
    recordId;
}
helloWorld.js in LWC

Hope this is helpful!