我的提示是这样的:
GET http://localhost:*
Error: connect ECONNREFUSED 127.0.0.1:4000
Request Headers
User-Agent: PostmanRuntime/7.26.5
Accept: */*
Postman-Token: *
Host: localhost:4000
Accept-Encoding: gzip, deflate, br
这个是没有启动服务器导致的,需要先启动服务器,在启动服务器的时候又提示:
连接数据库失败 MongoNetworkError: failed to connect to server [localhost:27010] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27010
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1138:16) {
name: 'MongoNetworkError',
errorLabels: [Array],
[Symbol(mongoErrorContextSymbol)]: {}
}]
at Pool.<anonymous> (F:\vue\Vue_项目\code\code\gshop-server_final\node_modules\mongodb-core\lib\topologies\server.js:564:11)
at Pool.emit (events.js:311:20)
at Connection.<anonymous> (F:\vue\Vue_项目\code\code\gshop-server_final\node_modules\mongodb-core\lib\connection\pool.js:317:12)
at Object.onceWrapper (events.js:418:26)
at Connection.emit (events.js:311:20)
at Socket.<anonymous> (F:\vue\Vue_项目\code\code\gshop-server_final\node_modules\mongodb-core\lib\connection\connection.js:246:50)
at Object.onceWrapper (events.js:418:26)
at Socket.emit (events.js:311:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
name: 'MongoNetworkError',
errorLabels: [ 'TransientTransactionError' ],
[Symbol(mongoErrorContextSymbol)]: {}
}
Done in 8.65s.
出现这个问题是没有启动数据库导致的,只需要在搜索中输入服务,找到MongoDB打开就可以了,我设置的是手动,因此开次开机都需要手动打开
然后再去测试接口,发现就可以了: