Why admin url is not found running from JS?

Viewed 20

In the routes/web.php of laravel 5.8 app I have defined :

Route::get('/adminPayConsultantInvoice/{invoice_id}', 'Server\AdminStripeController@payConsultantInvoice')->name('admin.pay-consultant-invoice');

but running from Javsscript :

   document.location='adminPayConsultantInvoice/'+invoice_id

I got 404 error in output of

 php artisan route:list

I see

|        | GET|HEAD                               | adminPayConsultantInvoice/{invoice_id}            | admin.pay-consultant-invoice    | App\Http\Controllers\Server\AdminStripeController@payConsultantInvoice              | web,checkLocale       |

I do not see why I have this errir and how it can be fixed ?

Thanks!

1 Answers

You have tried this

document.location="{{url('')}}/adminPayConsultantInvoice/"+invoice_id 

It works fine for me always

Related