在 Postman 中发布请求

问题描述 投票:0回答:1

我通过POSTMAN遇到这样的问题,无法发送POST请求,可能是什么问题? 邮递员控制台:

Error: localhost request not supported Network Request Headers User-Agent: PostmanRuntime/7.32.2 Accept: */* Cache-Control: no-cache Postman-Token: 815c2340-5ac3-4ab4-91be-8d62a5d6333b Host: localhost:8800 Accept-Encoding: gzip, deflate, br Connection: keep-alive

import User from "../models/user.model.js";

export const register = async (req,res)=> {
    try {
        const newUser = new User(req.body);
        
        await newUser.save();
        res.status(201).send("User has been created.");
    } catch (err) {
        res.status(500).send("Something went wrong!");
    }
};


//export const login = async (req,res)=> {};

//export const logout = async (req,res)=> {};
import express from "express";
import { register,  } from "../controllers/auth.controller.js";
const router = express.Router();

router.post("/register", register)
//router.post("/login", login)
//router.post("/logout", logout)

export default router;

enter image description here enter image description here

我是初学者,这是我第一次使用POSTMAN,所以不要太严厉地评判)

json request postman localhost
1个回答
0
投票

尝试关闭邮递员生成的标头。隐藏标头打开 然后再次发送。隐藏标头关闭

© www.soinside.com 2019 - 2024. All rights reserved.