Just trying to load a js library in a LWC. Cannot even get the thing to load. I just want it to load and do nothing.
Static resource here:
Name headerConfig
Namespace Prefix
Description
MIME Type text/javascript
Cache Control Private
Size 615 bytes
import { LightningElement } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { loadScript, loadStyle } from 'lightning/platformResourceLoader';
import headerConfig from '@salesforce/resourceUrl/headerConfig';
export default class UtahHeader extends LightningElement {
error;
successMessage = '';
utahHeaderInit = false;
renderedCallback() {
// if(this.utahHeaderInit) {
// return;
// }
// this.utahHeaderInit = true;
Promise.all([
loadScript(this, headerConfig)
])
.then(() => {
this.error = undefined;
this.showSuccessMessage();
alert('loaded');
// this.loadConfig();
// this.loadMainMenu();
})
.catch(error => {
this.error = error;
this.dispatchEvent(
new ShowToastEvent({
title: 'Errrorrr',
variant: 'error',
}),
);
});
}
showSuccessMessage() {
this.successMessage = 'loaded succ';
alert('scripts loaded succ');
}
<template>
<lightning-card title="Third Party Library Demo" icon-name="custom:custom19">
<p><b style="color:blue;">{successMessage}</b></p>
</lightning-card>
</template>
Any ideas what I'm doing wrong here? Tried to follow other posts but I'm able to rectify mine.. if I try to add error.message, it says it's an undefined property so I can't even find out what the issue is.