我想将波纹管post方法中收到的相同数据发送到另一个app.post方法。
app.post('/sign_up', (req, res) => {
var name = req.body.fullname,
email = req.body.email,
password = req.body.password,
cpassword = req.body.cpassword;
var base64Str = req.body.image;
var obj = { name: name, email: email, password: password, cpassword: cpassword, b:base64Str };
console.log("Server Recieved: ");
console.log(obj);
//Now here want to submit this data as post to another
//app.post("/get_data", function(req, res)) { //do something else } )
});
让我知道如何实现这一目标吗?
答案 0 :(得分:0)
您似乎想向网站中的另一个网址发出带有以下数据的发布请求。可以使用Fetch API
答案 1 :(得分:0)
您可以将命名函数用于'/ get_data'路由,并在'/ sign_up'路由的末尾调用该函数。
请参见下面的示例代码。
app.post('/sign_up', (req, res) => {
var name = req.body.fullname,
email = req.body.email,
password = req.body.password,
cpassword = req.body.cpassword;
var base64Str = req.body.image;
var obj = {
name: name,
email: email,
password: password,
cpassword: cpassword,
b: base64Str
};
console.log("Server Recieved: ");
console.log(obj);
//Now here want to submit this data as post to another
get_data(req, res);
});
app.post("/get_data", get_data);
const get_data = function(req, res)) {
//do something else
};
答案 2 :(得分:-1)
您可以尝试npm 请求模块。