laroute
laroute copied to clipboard
Uncaught TypeError: parameters.join is not a function
/js/laroute.js:24

var ajaxurl = laroute.url('ajax-'+$(this).data('action'), []);
L5.1 "lord/laroute": "^2.1"
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).
I have this error too what should i do? @aaronlord
What parameters are you passing to the laroute.url call?
url to my route like home @aaronlord
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', [])
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)
@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 I think it's a mistake and should be fixed.
2 years... Thx!
Still not fixed?