Skip to content

Instantly share code, notes, and snippets.

@dancinllama
Created December 19, 2018 03:51
Show Gist options
  • Save dancinllama/99ebc1c9afeb5d1243920552f0d7ed08 to your computer and use it in GitHub Desktop.
Save dancinllama/99ebc1c9afeb5d1243920552f0d7ed08 to your computer and use it in GitHub Desktop.
Loading moment.js in a LWC
import { LightningElement } from 'lwc';
import moment from '@salesforce/resourceUrl/moment';
import { loadScript } from 'lightning/platformResourceLoader';
export default class MomentStuffs extends LightningElement {
renderedCallback(){
Promise.all([
loadScript(this, moment + '/moment.js')
]).then(() => {
//Hey this works!
//moment() prints out stuff here in the render callback!
debugger;
})
.catch(error => {
debugger;
});
}
}
@himanshu089
Copy link

Hi, just did same code in my VS code and I am just trying to print all data of moment. Also, console log but nothing is getting printed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment