我正在对我的后端进行提取调用,这是调用。
\n\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然后这是我在后端发送呼叫的路线
\n\nrouter.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当我这样做时,正确的对象会在发回之前记录。这是记录内容的示例
\n\n{ __v: 0,\r\n updatedAt: 2018-10-19T15:47:16.809Z,\r\n createdAt: …Run Code Online (Sandbox Code Playgroud)