简体   繁体   English

Locu-node TypeError:无法调用未定义的方法'call'

[英]Locu-node TypeError: Cannot call method 'call' of undefined

I'm using the locu-node node.js library found here: https://github.com/Locu-Unofficial/locu-node , which is an API client for the Locu service. 我正在使用这里找到的locu-node node.js库: https//github.com/Locu-Unofficial/locu-node ,它是Locu服务的API客户端。 In the example code provided, you can perform a query by doing the following: 在提供的示例代码中,您可以通过执行以下操作来执行查询:

do_search = function() {
  var locu = require('locu');
  var my_client = locu.MenuItemClient(apiKey);
    my_client.search({
      name:'pizza',
      description:'delicious',
      locality:'san francisco'
    },
    function(result) {
      console.log(result);
    }
  );

exports.do_search = do_search;

This code is sitting in a handler.js module that I call via a route. 这段代码位于我通过路由调用的handler.js模块中。 When I call that route, I get this error: 当我调用该路由时,我收到此错误:

TypeError: Cannot call method 'call' of undefined at Object.MenuItemClient ... \\locu.js:179:15 TypeError:无法在Object.MenuItemClient中调用undefined方法'call'... \\ locu.js:179:15

, which is where the locu module tries to initialize the MenuItemClient. ,这是locu模块尝试初始化MenuItemClient的地方。 Has anyone used this library either successfully or run into this problem? 有没有人成功使用过此库或遇到此问题? Am I doing/not doing something stupid? 我在做/不做傻事吗?

使用new关键字。

  var my_client = new locu.MenuItemClient(apiKey);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM