我一直在关注回送文档中的一些教程。我目前正在尝试通过遵循本教程来运行API资源管理器:
https://docs.strongloop.com/display/public/LB/Use+API+Explorer
我创建了一个CoffeShop模型。并遵循创建POST请求的步骤。但是,我收到以下404错误。
{
"error": {
"name": "Error",
"status": 404,
"message": "There is no method to handle POST /Coffe%20Shops",
"statusCode": 404,
"stack": "Error: There is no method to handle POST /Coffe%20Shops\n at restUrlNotFound (..\\hello\\node_modules\\strong-remoting\\lib\\rest-adapter.js:339:17)\n at Layer.handle [as handle_request] (..\\hello\\node_modules\\express\\lib\\router\\layer.js:95:5)\n at trim_prefix (..\\hello\\node_modules\\express\\lib\\router\\index.js:312:13)\n at ..\\hello\\node_modules\\express\\lib\\router\\index.js:280:7\n at Function.process_params (..\\hello\\node_modules\\express\\lib\\router\\index.js:330:12)\n at next (..\\hello\\node_modules\\express\\lib\\router\\index.js:271:10)\n at ..\\hello\\node_modules\\body-parser\\lib\\read.js:129:5\n at invokeCallback (..\\hello\\node_modules\\raw-body\\index.js:262:16)\n at done (..\\hello\\node_modules\\raw-body\\index.js:251:7)\n at IncomingMessage.onEnd (..\\hello\\node_modules\\raw-body\\index.js:308:7)"
}
}
我从教程中克隆了git repo,它们运行正常。我已经按照所有步骤操作,但是我不知道是什么原因导致了此错误。
谁能帮我吗?
您拼写错误的“ CoffeeShop”可能是问题所在。“%20”建议您在名称中放置一个空格,以防止回送。
我按照这里的指示进行:
$ git clone https://github.com/strongloop/loopback-getting-started.git
$ cd loopback-getting-started
$ git checkout step1
$ npm install
并且能够毫无问题地获得Post请求。
我还创建了自己的自定义CoffeeShop持久化模型,并在未对其模板进行git clone的情况下再次尝试了该模型,并且没有任何问题:
coffee-shop.json
{
"name": "CoffeeShop",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"name": {
"type": "string",
"required": true
},
"city": {
"type": "string",
"required": true
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}
我的建议是将您的自定义解决方案与本教程提供的解决方案进行比较,或者快速重试一个新项目。
如前所述,没有您的代码,很难重现您的确切问题,但是它看起来像是语法错误。
版本:
npm 2.14.4
node 4.1.2
strongloop 6.0.0
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句