Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vuejs Laravel Axios创建请求_Laravel_Vue.js_Axios - Fatal编程技术网

Vuejs Laravel Axios创建请求

Vuejs Laravel Axios创建请求,laravel,vue.js,axios,Laravel,Vue.js,Axios,我有一个vuejs方法,它实现了axios,将put/create请求发送给我的LaravelAPI创建方法,并传递一些数据 create(data) { this.mute = true; window.axios.put('/api/showreels/create', {data}).then(({ data }) => { this.showreels.push(new Showreel(data)); this.mute = fal

我有一个vuejs方法,它实现了axios,将put/create请求发送给我的LaravelAPI创建方法,并传递一些数据

create(data) {
    this.mute = true;
    window.axios.put('/api/showreels/create', {data}).then(({ data }) => {
        this.showreels.push(new Showreel(data));
        this.mute = false;
    }).catch(error => {
            document.write(error.response.data);
    });
},
My api.php是使用以下资源设置的

//Showreel
Route::resource('/showreels' , 'ShowreelController' , [
 'except' => ['edit', 'show', 'store']
]);
我有一个create方法来处理请求并更新数据。(我在中添加了大量调试)

然而拉威尔给了我这个错误


不确定为什么会出现此错误?

看起来我在api.php中禁用了STORE选项,该选项关闭了post-request选项。post请求现在将引导我进入laravel中的store方法。

看起来我在api.php中禁用了store选项,这将关闭post请求选项。post请求现在将我带到laravel中的store方法。

我发现put请求调用的是我的update方法,而不是create方法。现在我只需要弄清楚如何创建,因为我的api不允许post请求。我已经弄清楚put请求调用的是我的update方法,而不是create方法。现在我只需要弄清楚如何创建,因为我的api不允许post请求。
    /**
 * Create a new resource.
 *
 * @return \Illuminate\Http\Response
 */
public function create(Request $request)
{

    $message = 'sdfsdfsdf';
    $message =  $message . $request->heading . 'BALLS';

    \App::abort(500, $message);

    $showreel = new Showreel();
    $showreel->heading = $request->heading;
    $showreel->subheading = $request->subheading;
    $showreel->detail =  $request->heading;
    $showreel->youtubeid =  $request->youtubeid;


    $showreel->heading = "test";
    $showreel->subheading = "test";
    $showreel->detail = "test";
    $showreel->youtubeid = "test";



    $showreel->save();

    return response($showreel->jsonSerialize(), Response::HTTP_CREATED);
}