{ var name = req.b-6ren">
gpt4 book ai didi

javascript - 将发布数据 "mutlipart"从一个 Nodejs 函数发送到另一个 Nodejs 函数

转载 作者:太空宇宙 更新时间:2023-11-04 02:45:42 27 4
gpt4 key购买 nike

我想将在下面的 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 } )

});

让我知道如何实现这一目标?

最佳答案

您可以为“/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
};

关于javascript - 将发布数据 "mutlipart"从一个 Nodejs 函数发送到另一个 Nodejs 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51135892/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com