I have added a payment method renderer javascript file to a magento 2 module. I want one of the functions in the js to redirect to another page on the site.
How do I get the base url so that I can generate the full url correctly?
Currently I have this js method renderer:
define(
[
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/view/payment/default'
],
function (quote, Component) {
'use strict';
return Component.extend({
defaults: {
template: 'VendorName_ModuleName/payment/mypaymentmethod'
},
startPayment: function(){
var url = "modulename/mypaymentmethod/generatepaymentrequest"
console.log(url);
// TODO prepend base url before redirecting
window.location.href = url;
},
});
}
);