I am getting this error how should i slove this can any me help me
this is myCode
import { LightningElement, track } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { subscribe, unsubscribe, onError } from 'lightning/empApi';
export default class DisconnectionNotice extends LightningElement {
channelName = '/event/Asset_Disconnection__e';
subscription = null;
@track status; // Tracks the disconnection status
// messageCallback;
// Subscribe to the Platform Event
connectedCallback() {
this.subscribeToEvent();
}
// Unsubscribe from the Platform Event
disconnectedCallback() {
this.unsubscribeFromEvent();
}
// Define the messageCallback function
messageCallback = (response) => {
console.log('New event received: ', JSON.stringify(response));
const payload = response.data.payload;
this.status = payload.Disconnected__c;
if (this.status) {
this.showSuccessToast('Asset Disconnected Successfully!');
} else {
this.showErrorToast('Asset Disconnection Failed.');
}
};
// Subscribe to the Platform Event
subscribeToEvent() {
subscribe(this.channelName, -1, this.messageCallback)
.then((response) => {
console.log('Subscription successful: ', JSON.stringify(response));
this.subscription = response;
})
.catch((error) => {
console.error('Subscription failed: ', error);
});
// Handle errors
onError((error) => {
console.error('Streaming API error: ', error);
});
}
// Unsubscribe from the Platform Event
unsubscribeFromEvent() {
if (this.subscription) {
unsubscribe(this.subscription, (response) => {
console.log('Unsubscribed from event: ', JSON.stringify(response));
});
}
}
// Show Success Toast
showSuccessToast(message) {
const event = new ShowToastEvent({
title: 'Success',
message: message,
variant: 'success',
});
this.dispatchEvent(event);
}
// Show Error Toast
showErrorToast(message) {
const event = new ShowToastEvent({
title: 'Error',
message: message,
variant: 'error',
});
this.dispatchEvent(event);
}
}