Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
"Uncaught TypeErrors" on server, but not on local environment for API call

I'm getting the three errors below when trying to add salesforce authentication and an api call on my site. The code works fine locally on node

Uncaught TypeError: jsforce.Connection is not a constructor

Uncaught (in promise) TypeError: Failed to resolve module specifier 'jsforce'

Uncaught (in promise) TypeError: Failed to resolve module specifier 'xmlhttprequest'

// JSForce Authentication
var jsforce = import('jsforce');
var XMLHttpRequest = import("xmlhttprequest").XMLHttpRequest;
var conn = new jsforce.Connection({
  loginUrl : 'https://test.salesforce.com'
});
conn.login('username_redacted_for_demo', 'KLJHiu76iUKAYIS87AI7as8878aslkxck', function(err, userInfo) {
  if (err) { 
    console.log(JSON.stringify(err));
    return console.error(err); 
  }

  UserAction();
});

// Apex Rest API Call
function UserAction() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
   if (this.readyState == 4 && this.status == 200) {
    console.log(this.responseText);
  }
};

xhttp.open("GET", "https://example.my.salesforce.com/services/apexrest/MDR_Account/");
xhttp.setRequestHeader("Authorization", "Bearer " + conn.accessToken);
 xhttp.setRequestHeader("Content-type", "application/json");
 xhttp.send();
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!