Building a custom module, where i need to make ajax call. I search on magento project i get


Method being used in


function(customer, urlBuilder, utils) {
    "use strict";
    return {
        getUrlForTotalsEstimationForNewAddress: function(quote) {
            var params = (this.getCheckoutMethod() == 'guest') ? {cartId: quote.getQuoteId()} : {};
            var urls = {
                'guest': '/guest-carts/:cartId/totals-information',
                'customer': '/carts/mine/totals-information'
            return this.getUrl(urls, params);

In order to use this.getUrl() in my custom module, i have added mageUtils and url-builder to my widget js file but don't work.

I would like to know where is it defined ? or how can i use that method ?

1 Answer 1


getUrl() function defined in


getUrl: function(urls, urlParams) {
            var url;

            if (utils.isEmpty(urls)) {
                return 'Provided service call does not exist.';

            if (!utils.isEmpty(urls['default'])) {
                url = urls['default'];
            } else {
                url = urls[this.getCheckoutMethod()];
            return urlBuilder.createUrl(url, urlParams);

You can use this function just add file path in your define function.


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.