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 &#34;57bcdb57bcdb255600e6d114e7afb9&#34; @ path &#34;_id&#34;</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

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -