簡體   English   中英

PUT 請求不運行 Knex 更新語法並且不引發任何錯誤,繼續加載 POSTMAN。 (Knex.js、PostgreSQL、Node.js)

[英]PUT Request Does Not Run Knex Update Syntax And Does Not Throw Any Error, Keeps Loading In POSTMAN. (Knex.js , PostgreSQL, Node.js)

 After creating an endpoint that handles a PUT request, I followed the knex documentation to update the record in the database, the result I get when I test using POSTMAN is: it keeps loading forever, I don't get any error or message in the terminal. But when I console.log(req.body) it shows in the terminal the JSON sent from POSTMAN is hitting the endpoint and I can see the data. I created other endpoints for GET requests using knex > documentation and it is working fine except for the PUT method. I have attached 3 images; the first shows how POSTMAN keeps loading forever, and the second shows the data I sent from POSTMAN being logged in the terminal. And the code showing the endpoint and knex syntax.

在此處輸入圖像描述 在此處輸入圖像描述

在此處輸入圖像描述

我想讓 knex 用它接收到的數據更新與記錄的 id 匹配的記錄。

我犯了一些語法錯誤。

app.put('/update', (req, res) => {
    // console.log(req.body)
    const { id, name, year, house, mobile, email, occupation, gender} = req.body
    db.select('*')
        .from('unity_gate')
        .where('id', '=', id)
        .update({name: name, year: year, house: house, mobile: mobile, occupation: occupation,
            gender: gender, email: email})
        .then(data => res.status(200).json('Success'))
        .catch(err => console.log('Error', err));
})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM