[英]i want to take the data from html page and store in a file as json data in node.js
以下是我想讀取文件的html代碼,並使用node.js將數據存儲在文件中
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>The Page Returned by Making Http Call to Node.js</title>
<style type="text/css">
table, td {
border:double;
}
</style>
</head>
<body>
<h1>Product Information Page</h1>
<table>
<tr>
<td>Product Id:</td>
<td>
<input type="text" />
</td>
</tr>
<tr>
<td>Product Name:</td>
<td>
<input type="text" />
</td>
</tr>
<tr>
<td></td>
<td>
<input type="button" id = "textFieldId" value="Save"/>
</td>
</tr>
</table>
</body>
</html>
以下是我想將用戶輸入文本字段寫入我的文件系統的Node.js代碼
app.get('/list_user', function (req, res) {
res.sendFile(path.join((__dirname + '/AppPages/MyPage.html')))
let inputContent = res.body;
console.log(inputContent);
JSON.stringify(inputContent);
fs.writeFile(__dirname+'/AppPages/data.json',inputContent,function(err){
if (err) throw err;
console.log('saved')
})
我進入data.json作為未定義
在代碼中沒有初始化數據對象的位置,但是看起來可以輸入內容
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.