The most simple way to use Postman

  1. Open Postman: Launch the Postman app.
  2. Create a Request: Click on the “New” button, then select “Request”. This creates a new tab for a request.
  3. Set Request Type to POST: On the new request tab, you’ll see a dropdown menu next to the URL field. Select “POST” from this dropdown.
  4. Enter Request URL: In the URL field, enter the endpoint URL. If you’re testing locally, it will likely be http://localhost:3001/authenticate.
  5. Set Headers: Under the Headers tab, make sure that you have set the content type to JSON. This is usually automatically set when you enter the body, but you can manually set it by adding a new header with Key as Content-Type and Value as application/json.
  6. Enter JSON Body: Click on the “Body” tab below the URL field, select “raw”, and then from the dropdown on the right of the textbox select “JSON”. Enter the JSON object you want to send. For your server, it expects a username, so you might enter something like:
    {
         
        "username": "sampleUser"
    }
    
  7. Send the Request: Click the “Send” button.

This is my code

const express = require("express");
const cors = require("cors");

const app = express();
app.use(express.json());
app.use(cors({
    origin: true }));

app.post("/authenticate", async (req, res) => {
   
  const {
    username } = req.body;
  return res.json({
    username: username, secret: "sha256..." });
});

app.listen(3001);

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-10 09:20:03       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-10 09:20:03       106 阅读
  3. 在Django里面运行非项目文件

    2024-01-10 09:20:03       87 阅读
  4. Python语言-面向对象

    2024-01-10 09:20:03       96 阅读

热门阅读

  1. php将文本内容写入一个文件(面向对象写法)

    2024-01-10 09:20:03       63 阅读
  2. php中的继承和接口

    2024-01-10 09:20:03       56 阅读
  3. Hive的时间处理函数from_unixtime和unix_timestamp

    2024-01-10 09:20:03       60 阅读
  4. 能源互联网:照亮我们绿色、智能的未来

    2024-01-10 09:20:03       64 阅读
  5. 【Leetcode】251.展开二维向量

    2024-01-10 09:20:03       50 阅读
  6. Unity两组Toggle一一对应关系

    2024-01-10 09:20:03       55 阅读
  7. Agisoft Metashape 地面点分类参数设置

    2024-01-10 09:20:03       62 阅读