嘿,我试图通过发布请求在我的nodejs中获取一些对象 因此,当我发送发布请求时,req.body.parm将采用变量自身而不是json或字符串
有例子
const variable = Markup.inlineKeyboard([[Markup.callbackButton('?', 'like')]])
app.post('/sendMessage', (req,res)=>{
// console.log(req.body);
// res.status(200).send('OK')
if(!req.body.user_id)
{
return res.status(402).send({
message: "UserId cannot be empty"
});
}
Bot.sendMessage(parseInt(req.body.user_id),req.body.message,req.body.variable);
res.status(200).send({message:'Message has been sent to ' + req.body.user_id});
});
我发送的请求是:
{"user_id":"815779314","message":"its a TEST","variable":"variable"}
所以我想在req.body.variable中获得const变量本身,我该怎么做?