小编Jul*_*tta的帖子

在react.js中添加列值

添加所有列值的最佳方法是什么?
JSON

[
  {
    "id": "men",
    "label": "men",
    "value": 3,
    "color": "#468df3"
  },
  {
    "id": "women",
    "label": "women",
    "value": 5,
    "color": "#ba72ff"
  },
  {
    "id": "children",
    "label": "children",
    "value": 5,
    "color": "#a1cfff"
  }
]
Run Code Online (Sandbox Code Playgroud)

我从服务器获取数据我想添加所有值并在控制台中显示它.例如,控制台中的const值= 3 + 5 + 5 = 13.

javascript

4
推荐指数
1
解决办法
96
查看次数

获取请求返回状态 cors 和可读流

我正在对我的后端进行提取调用,这是调用。

\n\n

\r\n
\r\n
    const response = await fetch(apiUrl + \'/recipes\', {\r\n      method: \'POST\',\r\n      headers: {\r\n        \'Content-Type\': \'application/json\',\r\n        \'Authorization\': `Token token=${user.token}`\r\n      },\r\n      body: JSON.stringify({\r\n        recipe: {\r\n          recipeId: uri\r\n        }\r\n      })\r\n    })
Run Code Online (Sandbox Code Playgroud)\r\n
\r\n
\r\n

\n\n

然后这是我在后端发送呼叫的路线

\n\n

\r\n
\r\n
router.post(\'/recipes\', requireToken, (req, res) => {\r\n  req.body.recipe.owner = req.user.id\r\n  Recipe.create(req.body.recipe)\r\n    .then(recipe => {\r\n      console.log(\'Recipe object saved is\', recipe)\r\n      res.status(201).json({ recipe: recipe.toObject() })\r\n    })\r\n    .catch(err => handle(err, res))\r\n})
Run Code Online (Sandbox Code Playgroud)\r\n
\r\n
\r\n

\n\n

当我这样做时,正确的对象会在发回之前记录。这是记录内容的示例

\n\n

\r\n
\r\n
{ __v: 0,\r\n  updatedAt: 2018-10-19T15:47:16.809Z,\r\n  createdAt: …
Run Code Online (Sandbox Code Playgroud)

javascript http fetch

2
推荐指数
1
解决办法
4024
查看次数

标签 统计

javascript ×2

fetch ×1

http ×1