You need to sign in to do that
Don't have an account?
using Superagent in lwc
Has anyone tried to use Superagent (https://github.com/visionmedia/superagent" target="_blank) in a lightning web component?
This is the js file I used for the static resource named superagent
https://cdn.jsdelivr.net/npm/superagent@5.0.5/dist/superagent.min.js
import { LightningElement } from 'lwc'; import { loadScript } from 'lightning/platformResourceLoader'; import superagent from '@salesforce/resourceUrl/superagent'; export default class BodaciousDisputatious extends LightningElement { superagentInitialized = false; renderedCallback() { if (this.superagentInitialized) { return; } Promise.all([ loadScript(this, superagent) // the static resource is not in an archive ]).then(() => { this.superagentInitialized = true; this.makeTheCall(); }) } makeTheCall() { superagent .get ('https://api.idk.com') .then((error, response) => { if (error) { console.error(error); } if (response) { console.warn(response); } }); } }All I get is get is not a function. Maybe I just have the Friday burnouts, maybe I need to look at it again after some beverages. But incase that dosn't help do any of you fine folks see anything wrong?
This is the js file I used for the static resource named superagent
https://cdn.jsdelivr.net/npm/superagent@5.0.5/dist/superagent.min.js

After a few tasty drinks and some sleep it was obvious what the issue was. Don't use the namespace of your lib in your import, duh. Use something like...