小编Gaz*_*Gaz的帖子

Node.js POST 请求在 Postman 中永远挂起

我已经按照教程成功地设置了一个注册系统,并且一直在尝试获取自己的数据来 POST 我的 MongoDB,但是 Postman 请求永远发送。我不确定我是否遗漏了某些内容或者我是否使用了不正确的语法?

\n\n

我只是想为我的 \xe2\x80\x98Hobby\xe2\x80\x99 模型发布两个字符串。

\n\n

hobbies.js (api) 包含在 paths/api 中。

\n\n
const express = require("express");\nconst router = express.Router();\nconst mongoose = require("mongoose");\n\nconst Hobbies = require("../models/Hobby");\n\n// @route   GET api/posts/test\n// @desc    Tests post routes\n// @access  Public - (Private routes are for registered and logged in users)\nrouter.get("/test", (req, res) => res.json({ msg: "Hobbies page Works" }));\n\nrouter.post("/newhobby", (req, res) => {\n  //else create the new user in the DB using the data input by user\n  const newHobby = new …
Run Code Online (Sandbox Code Playgroud)

mongoose mongodb node.js

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

标签 统计

mongodb ×1

mongoose ×1

node.js ×1