0

I am trying to call the external js file using requiresjs

require-js-config.js:

var config = {
    map: {
        '*': {
            Stronghold:'https://api.strongholdpay.com/v2/js'
        }
    },shim: {
            "Stronghold": {
                'deps': ["jquery"]
            }
        }
};

Js file call

require(['jquery','jquery/ui','Stronghold'], function($,Stronghold){

  var strongholdPay = Stronghold.Pay({
      environment: 'xxxxxxxxx',
      publishableKey: 'xxxxxxxxxx'
  });

});

Error:

Uncaught TypeError: Stronghold is undefined

1 Answer 1

0

In your require-js-config.js: add code like this one :

var config = {
  paths: {
    'Stronghold': 'https://api.strongholdpay.com/v2/js'
  }
};

And now in phtml file called like this one :

require(['jquery','jquery/ui','Stronghold'], function($,Stronghold){
  var strongholdPay = new Stronghold();
       OR
  var strongholdPay = Stronghold.Pay({
      environment: 'xxxxxxxxx',
      publishableKey: 'xxxxxxxxxx'
  });

});
3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.