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();
}