我正在學習關於均值堆棧和我以下的平均在thinkster.io https://thinkster.io/mean-stack-tutorial/測試REST路線的捲曲-X PUT,返回404
教程在我的「開放REST路由」部分。我試圖使用捲曲用命令把一個給予好評:
curl -X PUT http://localhost:3000/posts/55387047f2334d2
c227e8079/upvote
我收到以下錯誤信息:
C:\Users\Michael\Desktop>curl -X PUT http://localhost:3000/posts/55387047f2334d2
c227e8079/upvote
<h1>Not Found</h1>
<h2>404</h2>
<pre>Error: Not Found
at app.use.res.render.message (C:\Users\Michael\Desktop\flapper-news\app.js:
39:13)
at Layer.handle [as handle_request] (C:\Users\Michael\Desktop\flapper-news\n
ode_modules\express\lib\router\layer.js:82:5)
at trim_prefix (C:\Users\Michael\Desktop\flapper-news\node_modules\express\l
ib\router\index.js:302:13)
at C:\Users\Michael\Desktop\flapper-news\node_modules\express\lib\router\ind
ex.js:270:7
at Function.proto.process_params (C:\Users\Michael\Desktop\flapper-news\node
_modules\express\lib\router\index.js:321:12)
at next (C:\Users\Michael\Desktop\flapper-news\node_modules\express\lib\rout
er\index.js:261:10)
at C:\Users\Michael\Desktop\flapper-news\node_modules\express\lib\router\ind
ex.js:603:15
at next (C:\Users\Michael\Desktop\flapper-news\node_modules\express\lib\rout
er\index.js:246:14)
at Function.proto.handle (C:\Users\Michael\Desktop\flapper-news\node_modules
\express\lib\router\index.js:166:3)
at router (C:\Users\Michael\Desktop\flapper-news\node_modules\express\lib\ro
uter\index.js:35:12)</pre>
我的貓鼬架構定義有關應用程序的module.exports =應用程序。 JS,所以我不知道還有什麼要做。我檢查了我的複製和粘貼技巧,沒有錯別字。
謝謝。是的,我做了上一步。一切都很好,包括使用curl創建帖子。你是什麼意思檢查你的服務器可以通過本地主機解析?我正在使用curl,並且尚未在本地主機上運行任何內容。我是不是該?然後,我將在教程中繼續前進。 – Sticky
好吧,我猜你在Mac上,一切都在本地安裝。我不是Mac專家,所以我不知道我是否可以幫助您解決特定於Mac的主機/ DNS路由問題,但我懷疑是這種情況。 所以根據教程,你剛剛得到貓鼬配置,你正在運行mongo。當你在終端運行'mongo'命令時會發生什麼?一切都很好,在這裏對嗎? –
你是主應用主頁加載正確,對嗎?當你運行'curl http:// localhost:3000/posts' –