gpt4 book ai didi

rest.client stuck on waiting(REST.Client坚持等待)

转载 作者:bug小助手 更新时间:2023-10-25 10:19:30 25 4
gpt4 key购买 nike



The handler for / request is

/请求的处理程序是


module.exports = {  
homepageHandler: async function (req, res) {
console.log(`index page.`);
return JSON.stringify({
"message": "welcome"
});
}
}

It is called from app.js - app.get('/', indexControllerModule.homepageHandler);

从app.js-app.get(‘/’,indexControllerModule.home epageHandler)调用;


I am trying to test this endpoint using Rest Client extension.

我正在尝试使用REST客户端扩展来测试这个端点。


Name: REST Client
Id: humao.rest-client
Description: REST Client for Visual Studio Code
Version: 0.25.1
Publisher: Huachao Mao
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=humao.rest-client

The request is

我的要求是


GET http://localhost:4000/
Content-Type: application/json

When I click on send request, the client seem to be stuck in waiting` state (see lower left corner) of the pic.

当我点击发送请求时,客户端似乎停留在图片的等待状态(见左下角)。


Seem the request is received (output of console.log(`index page.`)) from index handler but the response isn't received. Why?

似乎收到了来自索引处理程序的请求(console.log(`index page.`)的输出),但没有收到响应。为什么?


I tried using Promise.resolve for return value but that didn't solve the issue.

我尝试使用Promise.Resolve作为返回值,但没有解决问题。


return Promise.resolve(JSON.stringify({
"message": "welcome"
}));

enter image description here


enter image description here


更多回答
优秀答案推荐

silly me! I didn't return any response from the handler

我真傻!我没有从处理程序返回任何响应


added res.status(200).send(body)

已添加Res.Status(200)。发送(正文)


更多回答

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com