如何在Node.js中正确导出函数?

时间:2019-05-01 14:54:35

标签: javascript node.js

当我尝试调用无服务器功能时,我得到了def test(N): x1 = np.random.uniform(low=1, high=3, size=N) x2 = np.array([2, 4, 6]) x3 = np.array((3, 6, 9)) ind = pd.DataFrame({'x1': x1, 'x2': x2, 'x3': x3}) return (ind) ,我认为导出功能时我做错了一些事情,

我正在尝试安排我的项目,以便可以轻松导入Type Error login is not a function文件夹中的所有功能 我有这样的目录结构:

utils/

handler.js文件

handler.js
utils/
  login.js
  index.js

index.js文件

"use strict";
const {login} = require("./utils");

const username = 'user';
const password = 'pass';

module.exports.scrape = (event, context, callback) => {
  login(username, password)
      .catch(error =>
      callback(new Error(`Error scraping ${event}: ${JSON.stringify(error)}`))
    );
};

login.js文件

module.exports = {
    login: require("./login"),
  };

1 个答案:

答案 0 :(得分:-1)

在handler.js文件中,在需要使用程序的同时获取登录对象

  

const login = require(“ ./ utils”)。login;

相关问题