使用 Lumen 的简单 POST
Simple POST using Lumen
我在 routes.php 中有以下方法:
$app->post('insertGender', function ($NAME) {
$result = DB::insert("INSERT INTO HK_GENDER (NAME) VALUES (?)",[$NAME]);
return ($result)? "wow":"Noo";
});
我尝试使用 Postman 通过表单传递参数
我得到一个错误
Missing argument 1 for Closure::{closure}()
in routes.php line 93
at Application->Laravel\Lumen\Concerns\{closure}('2', 'Missing argument 1 for Closure::{closure}()', '93', array()) in routes.php
at Closure->{closure}()
为什么提供的参数没有被使用?
正确的方法是从请求中获取数据,像这样:
$app->post('insertGender', function (Illuminate\Http\Request $request) {
$NAME = $request->input('NAME');
$result = DB::insert("INSERT INTO HK_GENDER (NAME) VALUES (?)",[$NAME]);
return ($result)? "wow":"Noo";
});
我在 routes.php 中有以下方法:
$app->post('insertGender', function ($NAME) {
$result = DB::insert("INSERT INTO HK_GENDER (NAME) VALUES (?)",[$NAME]);
return ($result)? "wow":"Noo";
});
我尝试使用 Postman 通过表单传递参数
Missing argument 1 for Closure::{closure}()
in routes.php line 93
at Application->Laravel\Lumen\Concerns\{closure}('2', 'Missing argument 1 for Closure::{closure}()', '93', array()) in routes.php
at Closure->{closure}()
为什么提供的参数没有被使用?
正确的方法是从请求中获取数据,像这样:
$app->post('insertGender', function (Illuminate\Http\Request $request) {
$NAME = $request->input('NAME');
$result = DB::insert("INSERT INTO HK_GENDER (NAME) VALUES (?)",[$NAME]);
return ($result)? "wow":"Noo";
});