Javascript 使用环回API资源管理器
我一直在关注环回文档中的一些教程。我目前正试图通过以下教程运行API explorer: 我创建了一个咖啡店模型。并遵循创建POST请求的步骤。然而,我得到以下404错误Javascript 使用环回API资源管理器,javascript,loopbackjs,Javascript,Loopbackjs,我一直在关注环回文档中的一些教程。我目前正试图通过以下教程运行API explorer: 我创建了一个咖啡店模型。并遵循创建POST请求的步骤。然而,我得到以下404错误 { "error": { "name": "Error", "status": 404, "message": "There is no method to handle POST /Coffe%20Shops", "statusCode": 404, "stack": "Erro
{
"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请求
我还创建了自己的自定义咖啡店持久化模型,并在没有对其模板进行git克隆的情况下再次尝试了该模型,并且没有出现任何问题:
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
在没有看到项目的情况下很难进行调试,但是您的项目中肯定存在配置问题。你能把你所拥有的上传到github回购并发布链接吗?哇。。。事实上,问题是一个空间。。。我觉得自己好笨,哈哈。非常感谢你!