【发布时间】:2017-10-16 22:56:46
【问题描述】:
我正在尝试从 JS 文件 server/script/myScripts.js 调用名为 models/customerProfile.js 的 loopback model.js 文件中的函数,但出现此错误:
请求 GET /api/CustomerProfiles/verifyCustomer?id=38733 的未处理错误:TypeError:myScripts.verifyCustomerProfile 不是函数
我想将我所有的通用函数保存在这个 myScripts 文件中,并从我的 model.js 文件中调用它们。
我在 customerProfile.js 模型文件中执行了以下操作以包含脚本:
var myScripts = require('../../server/script/myScripts');
然后在我的代码中我引用它如下:
myScripts.functionName();
它不起作用。
【问题讨论】:
-
请阅读Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - 总结是这不是解决志愿者的理想方式,并且可能会适得其反。请不要将此添加到您的问题中。
标签: javascript loopbackjs loopback