I have created a remote method in my model named "FreeEmailProviders" that contains fields "id" and "domainname".
我在我的模型中创建了一个名为“FreeEmailProviders”的远程方法,其中包含字段“id”和“domainname”。
The code for creating the remote method is as follows:
创建远程方法的代码如下:
FreeEmailProviders.checkEmailDomain = function(email, cb) {
cb(null, email);
};
FreeEmailProviders.remoteMethod(
'checkEmailDomain',
{
http: {path: '/checkEmailDomain', verb: 'get'},
accepts: {arg: 'email', type: 'string'},
returns: {arg: 'isEmailFreeProvider', type: 'string'}
}
);
Now when i am running the application, this method is not displaying in the list of APIs for this method.
现在,当我运行应用程序时,此方法不会显示在此方法的API列表中。
When i am running the api directly in the browser, that is when i am calling the url: http://localhost:4000/api/FreeEmailProviders/checkEmailDomain?email=test@gmail.com
当我在浏览器中直接运行api时,就是当我调用url时:http:// localhost:4000 / api / FreeEmailProviders / checkEmailDomain?email=test@gmail.com
I am getting the below error:
我收到以下错误:
{"error":{"name":"Error","status":404,"message":"Unknown \"FreeEmailProviders\" id \"checkEmailDomain\".","statusCode":404,"code":"MODEL_NOT_FOUND","stack":"Error: Unknown \"FreeEmailProviders\" id \"checkEmailDomain\".\n at Function.convertNullToNotFoundError }}
Can anyone help me with this ?
谁能帮我这个 ?
1 个解决方案
#1
0
I ran into the same problem. After 3 hours I figured I had a typo in the *.js file.
我遇到了同样的问题。 3个小时后我发现* .js文件中有拼写错误。
If you used the model generator you should not run into this issue. If you created the files yourself make sure the .json and .js file in common/models have exact the same name except for the extension.
如果您使用了模型生成器,则不应该遇到此问题。如果您自己创建了文件,请确保common / models中的.json和.js文件具有完全相同的名称(扩展名除外)。
It would be nice if Loopback throws an error in such cases.
如果Loopback在这种情况下抛出错误,那将是很好的。
#1
0
I ran into the same problem. After 3 hours I figured I had a typo in the *.js file.
我遇到了同样的问题。 3个小时后我发现* .js文件中有拼写错误。
If you used the model generator you should not run into this issue. If you created the files yourself make sure the .json and .js file in common/models have exact the same name except for the extension.
如果您使用了模型生成器,则不应该遇到此问题。如果您自己创建了文件,请确保common / models中的.json和.js文件具有完全相同的名称(扩展名除外)。
It would be nice if Loopback throws an error in such cases.
如果Loopback在这种情况下抛出错误,那将是很好的。