如何将带有node.js后端的SAPUI5前端中的数据插入数据库中?

时间:2019-03-25 12:31:00

标签: javascript html node.js rest sapui5

我将SAPUI5用于前端,将node.js用于后端和SQL关系数据库。

这个主题是我的新手,有点困惑。

基本上,我有一个带有一些复选框和一个数字输入参数的SAPUI5前端。

<VBox>
    <CheckBox id="given_name" name="given_name")>
    <CheckBox id="last_name" name="last_name"/>
    <StepInput id="step_input">
 </VBox>
    <Button text="create" press="onpress"/>

JavaScript onPress按钮

onpress : function() {
var xhttp = new XMLHttpRequest();
xhhtp.onreadystatechange = function() {
if(xhttp.readyState === 4 && xhttp.status === 200){

alert(http.responsetext)
     }
};
xhttp.open("POST", "node/testing", true);
xhttp.send();
}

node.js

var express = require("express");

var bodyParser =require("body-parser");



module.exports = function () {

                var app = express.Router();    
                app.use(express.bodyParser());
                app.post("/testing", function (req, res) {    
                      var client = req.db;
                      res.send(req.body);     
                      console.log(req.body.given_name);

                });

我无法访问前端输入,并且不确定100%是否是随后从/ testing插入的正确方法。 感谢您的帮助!

0 个答案:

没有答案