JSON 方法 POST 使用 Alamofire 和 SwiftyJSON

JSON method POST with Alamofire and SwiftyJSON

我正在尝试将数据(参数)发送到我的本地后端:

这是一些代码:

Swift:

let parameters: Parameters = ["firstname": "User", "age": "33"]

        NetworkManager.sharedInstance.manager.request(localServer,
                                                      method: .post,
                                                      parameters: parameters,
                                                      encoding: JSONEncoding.default,
                                                      headers: [:]).responseString { response in
            switch response.result {
                case .success(let value):
                    let json = JSON(value)
                    print("JSON: \(json)")
                case .failure(let error):
                    print(error)
            }
        }

SQL-Table 所需属性:

CREATE TABLE public.employee 
(
    id SERIAL PRIMARY KEY,
    firstName CHARACTER VARYING(30),
    tabel CHARACTER VARYING(30),
    age INTEGER,
    organization CHARACTER VARYING(30)
);

但只有第二个参数 AGE 发送到后端。参数 FIRSTNAME 为 Null :(

提前感谢您的任何建议!

这是应用程序服务器端的别名

api.post("/employee/req", jsonParser, function(request, response){
        let { name, age } = request.body;
        pool.query('insert into public.employee (firstname, age) values (, )', [name, age], (error, results) => {
            if (error) {
                throw error
            }
            response.status(201).send('User added')
        })