Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: parameters.join is not a function #22

Open
assada opened this issue Aug 14, 2015 · 10 comments
Open

Uncaught TypeError: parameters.join is not a function #22

assada opened this issue Aug 14, 2015 · 10 comments

Comments

@assada
Copy link

assada commented Aug 14, 2015

/js/laroute.js:24

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

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

@aaronlord
Copy link
Owner

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).

@waqasraza123
Copy link

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

@aaronlord
Copy link
Owner

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

@waqasraza123
Copy link

url to my route like home @aaronlord

@richiej053
Copy link

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', [])

@waqasraza123
Copy link

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
#22 (comment).

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

@3amprogrammer
Copy link

3amprogrammer commented May 30, 2016

@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.

@meteorlxy
Copy link

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

@assada
Copy link
Author

assada commented Jun 23, 2017

2 years... Thx!

@ADRDev
Copy link

ADRDev commented Aug 13, 2018

Still not fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants