function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Anshuma YadavAnshuma Yadav 

How to write imperative wire inside the connectedCallback event in JavaScript using LWC component?

I am writing the below code for the same but it's not working.

 connectedCallback(){
            const messageCallback  = (response) => {
                console.log('New message received3 : ', JSON.stringify(response));
                getRecordList({recordId : this.recordId})
                    .then(result => {
                        this.wrapperList2 = result;
                        console.log('result1 ',JSON.stringify(this.wrapperList2));
                    })
                    .catch(error => {
                        console.log('Errorured2:- '+error.body.message);
                    });
            }
           
            console.log('Inside connected callback4');
            subscribe(this.channelName, -1, messageCallback)
            .then(response =>
                        {
                            console.log('****Subscription request fulfilled****5 ', JSON.stringify(response.channel));
                        })        
        }


Thankyou!!