在Postman中发布请求

fzwojiic  于 2023-04-30  发布在  Postman
关注(0)|答案(1)|浏览(208)

我通过POSTMAN遇到了这样的问题,我不能发送POST请求,可能是什么问题? Postman 控制台: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;

我是一个初学者,这是我第一次使用POSTMAN,所以不要太苛刻地判断)

相关问题