Home > front end >  The POST method is not supported for this route. Supported methods: GET, HEAD. I Want To save data f
The POST method is not supported for this route. Supported methods: GET, HEAD. I Want To save data f

Time:10-03

Api Controller

public function store(Request $request)
{
   $statistics = Statistics::create($request->all());
    return response()->json($statistics, 201);
}

route Route::get('statistics',[StatisticsController::class,'store']);

CURL Function

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,"http://localhost/kdk_local/statistics");
        curl_setopt($ch, CURLOPT_POSTFIELDS, 
       "game_id=3&user_id=3&bet=3&win=3&session_id=3");
        curl_exec($ch);
        curl_close($ch);

CodePudding user response:

Please clear the route cache:

php artisan route:clear

If don't work remove this file:

bootstrap/cache/routes-v7.php

or

bootstrap/cache/routes.php

CodePudding user response:

In the route file make it post from get:

Route::post('statistics', [StatisticsController::class,'store']);

Use API route (api.php) for external API call.

  • Related