程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了尝试使用 axios 发送数据时出现错误 404 not found laravel/vue大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决尝试使用 axios 发送数据时出现错误 404 not found laravel/vue?

开发过程中遇到尝试使用 axios 发送数据时出现错误 404 not found laravel/vue的问题如何解决?下面主要结合日常开发的经验,给出你关于尝试使用 axios 发送数据时出现错误 404 not found laravel/vue的解决方法建议,希望对你解决尝试使用 axios 发送数据时出现错误 404 not found laravel/vue有所启发或帮助;

我正在尝试使用 axios 将数据从 Vue.Js 保存到 Laravel 控制器,但是当我尝试使用邮递员和控制台时,我收到了这个 404 not fund 错误。

在我尝试将 axios 路径更改为:

axios.post('storeInvoice',{item: this.SELEctedItem,invoice_ID:this.invoice_ID}).then(response=>{
                    console.log(responsE);
                })

我得到 405 方法不允许 web.php

Route::post('storeInvoice',[InvoiceController::class,'storeInvoice']);

Items.vue

  axios.post('http://127.0.0.1:8000/storeInvoice',invoice_ID:this.invoice_ID}).then(response=>{
                    console.log(responsE);
                })

发票控制器.php


    public function storeInvoice(request $request){

      dd('added'); //just for tesTing purpose
    }

完整的 web.php

<?php

use Illuminate\Support\Facades\Route;
use App\http\Controllers\categoryController;
use App\http\Controllers\CustomerController;
use App\http\Controllers\ItemController;
use App\http\Controllers\InvoiceController;
use App\http\Controllers\CompanyDetailsController;


Route::get('/',function () {
    return vIEw('welcome');
});

Auth::routes();

Route::get('/home',[App\http\Controllers\HomeController::class,'index'])->name('home');
Auth::routes();

Route::get('/home','App\http\Controllers\HomeController@index')->name('home')->mIDdleware('auth');

Route::group(['mIDdleware' => 'auth'],function () {

    Route::resource('categorIEs',categoryController::class);
    Route::resource('customers',CustomerController::class);
    Route::resource('items',ItemController::class);
    Route::resource('invoices',InvoiceController::class);

    Route::get('invoice/export','export'])->name('exporTinvoice');
    Route::get('item/export',[ItemController::class,'export'])->name('exportItem');
    Route::get('customers/export',[CustomerController::class,'export'])->name('exportCustomer');

    Route::post('storeInvoice',[App\http\Controllers\InvoiceController::class,'storeInvoice']);
});

Route::group(['mIDdleware' => 'auth'],function () {
    Route::resource('user','App\http\Controllers\UserController',['except' => ['show']]);
    Route::get('profile',['as' => 'profile.edit','uses' => 'App\http\Controllers\ProfileController@edit']);
    Route::put('profile',['as' => 'profile.update','uses' => 'App\http\Controllers\ProfileController@update']);
    Route::put('profile/@R_674_5747@d',['as' => 'profile.@R_674_5747@d','uses' => 'App\http\Controllers\ProfileController@@R_674_5747@d']);
});

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

大佬总结

以上是大佬教程为你收集整理的尝试使用 axios 发送数据时出现错误 404 not found laravel/vue全部内容,希望文章能够帮你解决尝试使用 axios 发送数据时出现错误 404 not found laravel/vue所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。