node.js - 如何在nodejs中存储req.body.state
问题描述
这是node js中服务器的后端部分
stub.PostWorkflowResults(
{
workflow_id: "Demographics",
inputs: [
{data: {//need req.body.input here //}}
]
},
metadata,
(err, response) => {
if(response){
console.log(response)
}else {
console.log(err)
}
我使用了bodyparser。需要的是将 req.body.input 放入对象中{data: {//need req.body.input here //}}
解决方案
为什么不实现这样的代码?
app.post('/', function(req, res){
stub.PostWorkflowResults(
{
workflow_id: "my-custom-workflow",
inputs: [
{
data: {
image: {
url: req.body.input // guessing that your input is a url
}
}
}
]
},
metadata,
(err, response) => {
if (err) {
throw new Error(err);
}
if (response.status.code !== 10000) {
throw new Error("Post workflow results failed, status: " + response.status.description);
}
// Since we have one input, one output will exist here.
const result = response.results[0]
// One output is present for each model in the workflow.
for (const output of result.outputs) {
console.log("Predicted concepts for model: " + output.model.name);
for (const concept of output.data.concepts) {
console.log("\t" + concept.name + " " + concept.value);
}
console.log();
}
}
);
});
推荐阅读
- android - Fragment not showing up with recycleView
- php - visual composer front end text error
- java - MongoDb 的 JDBC 驱动程序是否存在?
- android - 打盹模式、电池优化白名单、AlarmManager 比 9 分钟更频繁
- git - Git 或 GitPython 检查文件是否已删除
- io - 非超前读取后的位置
- jquery - html5对象自动播放停止不起作用
- typescript - 当我只有一个实例时,Typescript observable 永远不会更新
- ruby - 如何在硒测试中显示浏览页面中的元素?
- c# - c#返回iso datetime而不是json datetime