laroute icon indicating copy to clipboard operation
laroute copied to clipboard

Uncaught TypeError: parameters.join is not a function

Open assada opened this issue 10 years ago • 10 comments
trafficstars

/js/laroute.js:24

var ajaxurl = laroute.url('ajax-'+$(this).data('action'), []);

L5.1 "lord/laroute": "^2.1"

assada avatar Aug 14 '15 10:08 assada

Do you have any more details on this?

Based on what you've presented, an error is being thrown for essentially [].join('/') (which is vanilla js and shouldn't error).

aaronlord avatar Nov 19 '15 02:11 aaronlord

I have this error too what should i do? @aaronlord

waqasraza123 avatar Dec 24 '15 23:12 waqasraza123

What parameters are you passing to the laroute.url call?

aaronlord avatar Dec 26 '15 20:12 aaronlord

url to my route like home @aaronlord

waqasraza123 avatar Dec 27 '15 10:12 waqasraza123

The problem is you are not passing in the 2nd parameter so you are trying to call .join on null, try passing in an empty array url('home/index', [])

richiej053 avatar Jan 15 '16 11:01 richiej053

why we are passing null as second argument?

On Fri, Jan 15, 2016 at 4:31 PM, richiej053 [email protected] wrote:

The problem is you are not passing in the 2nd parameter so you are trying to call .join on null, try passing in an empty array url('home/index', [])

— Reply to this email directly or view it on GitHub https://github.com/aaronlord/laroute/issues/22#issuecomment-171938647.

WAQAS RAZA https://www.odesk.com/users/~0117b5cb460d5341a5 Student at NUST , SEECS Web Developer at UpWork (Formerly odesk)

waqasraza123 avatar Jan 16 '16 12:01 waqasraza123

@richiej053 its actually join on an object.

The problem is here:

// Generate a fully qualified URL to the given path.
// laroute.route('url', [params = {}])
url : function (route, parameters) {
    parameters = parameters || {};

    return routes.url(route, parameters);
},

If you don't pass any parameter an empty object is assigned by default. In next step there is a check if parameters variable is empty:

url: function (url, parameters) {
    parameters = parameters || [];

    var uri = url + '/' + parameters.join('/');

    return this.getCorrectUrl(uri);
},

But its not. parameters = parameters || []; this line is wrong and an empty array will never apper here. An empty object passed to this function happens to be true ({} == true after coercion). @aaronlord please fix this issue or tell us why you are passing there an empty object.

3amprogrammer avatar May 30 '16 06:05 3amprogrammer

@3amprogrammer I think it's a mistake and should be fixed.

meteorlxy avatar Jun 23 '17 09:06 meteorlxy

2 years... Thx!

assada avatar Jun 23 '17 17:06 assada

Still not fixed?

ADRDev avatar Aug 13 '18 18:08 ADRDev