node.js - Having trouble with Mongod testing a route -
i've been following online tutorial @ thinkster "building first mean stack app" @
https://thinkster.io/mean-stack-tutorial#beginning-node
im trying test route see if correct using
curl -x put http://localhost:8080/posts/<post id>/upvote
and mongod throws 505 error saying
<h1>cast objectid failed value "57bcdb57bcdb255600e6d114e7afb9" @ path "_id"</h1>
casterror: cast objectid failed value "57bcdb57bcdb255600e6d114e7afb9" @ path "_id" @ mongooseerror.casterror (/home/ubuntu/workspace/flapper-news/node_modules/mongoose/lib/error/cast.js:19:11) @ objectid.cast (/home/ubuntu/workspace/flapper-news/node_modules/mongoose/lib/schema/objectid.js:147:13) @ objectid.castforquery (/home/ubuntu/workspace/flapper-news/node_modules/mongoose/lib/schema/objectid.js:187:15) @ cast (/home/ubuntu/workspace/flapper-news/node_modules/mongoose/lib/cast.js:208:32) @ query.cast (/home/ubuntu/workspace/flapper-news/node_modules/mongoose/lib/query.js:2653:10) @ query.findone (/home/ubuntu/workspace/flapper-news/node_modules/mongoose/lib/query.js:1284:10) @ /home/ubuntu/workspace/flapper-news/node_modules/mongoose/lib/query.js:2230:21 @ new promise.es6 (/home/ubuntu/workspace/flapper-news/node_modules/mongoose/lib/promise.js:45:3) @ query.exec (/home/ubuntu/workspace/flapper-news/node_modules/mongoose/lib/query.js:2223:10) @ /home/ubuntu/workspace/flapper-news/routes/index.js:37:9 @ paramcallback (/home/ubuntu/workspace/flapper-news/node_modules/express/lib/router/index.js:404:7) @ param (/home/ubuntu/workspace/flapper-news/node_modules/express/lib/router/index.js:384:5) @ function.process_params (/home/ubuntu/workspace/flapper-news/node_modules/express/lib/router/index.js:410:3) @ next (/home/ubuntu/workspace/flapper-news/node_modules/express/lib/router/index.js:271:10) @ function.handle (/home/ubuntu/workspace/flapper-news/node_modules/express/lib/router/index.js:176:3) @ router (/home/ubuntu/workspace/flapper-news/node_modules/express/lib/router/index.js:46:12)
i checked see if id , object existed entering
curl http://localhost:8080/<post id>/posts
and verified object indeed there
here cloud9 workspace if want take closer cloud9workspace
i have no idea went wrong, possible has mongodb version? (its later 1 in tutorial)
thank in advance time , hope can help!
it looks string passing objectid malformed (it's long). mongo objectids 24 characters (12-byte) strings. particular id has 30 characters
Comments
Post a Comment