+ Start a Discussion
Tim MaysTim Mays 

using Superagent in lwc

Has anyone tried to use Superagent (https://github.com/visionmedia/superagent" target="_blank) in a lightning web component?
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) {

          loadScript(this, superagent) // the static resource is not in an archive 
        ]).then(() => {
            this.superagentInitialized = true;

    makeTheCall() {
        .get ('https://api.idk.com')
        .then((error, response) => {
            if (error) {
            if (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
Best Answer chosen by Tim Mays
Tim MaysTim Mays
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...
import superagentResourceUrl from '@salesforce/resourceUrl/superagent';
loadScript(this, superagentResourceUrl)