tighten / ziggy

Use your Laravel routes in JavaScript.
MIT License
3.91k stars 248 forks source link

TypeError: Cannot call a class as a function #643

Closed dennismetz closed 1 year ago

dennismetz commented 1 year ago

Ziggy version

v1.6.0

Laravel version

v10.13.2

Description

I have upgraded from Laravel 7 to 10 and ziggy 0.9.4 to 1.6.0 After upgrading the NPM dependencies, I get the following error in the console:

[Vue warn]: Error in created hook: "TypeError: Cannot call a class as a function"

I have followed the instructions so far and entered everything, but unfortunately face the same problem as described here at the time: https://github.com/tighten/ziggy/issues/238#issuecomment-987231976

Ziggy call and context

axios.get(route('base_data'))

Ziggy configuration

// I have significantly more routes (>70)
const Ziggy = {"url":"abc.local","port":null,"defaults":{},"routes":{"dashboard":{"uri":"dashboard","methods":["GET","HEAD"]}};

if (typeof window !== 'undefined' && typeof window.Ziggy !== 'undefined') {
    Object.assign(Ziggy.routes, window.Ziggy.routes);
}

export { Ziggy };

Route definition

Route::get('/dashboard/', 'DashboardController@baseData')->name('dashboard');
bakerkretzmar commented 1 year ago

How are you configuring Ziggy? Using @routes? Or the Vue plugin? Or manually?

It looks like your global route function isn't getting set up properly, can you share more code showing every part of how you've installed and set up Ziggy, and the component that error is happening in?