module.exports = app => {
app.on(['pull_request.opened'],async context => {
let id = 'some string'
exports.id = id
})
}
我是 JavaScript 新手。我想将“id”变量导出到其他模块,但我无法在其他模块中读取它。有什么办法吗?
module.exports = app => {
app.on(['pull_request.opened'],async context => {
let id = 'some string'
exports.id = id
})
}
我是 JavaScript 新手。我想将“id”变量导出到其他模块,但我无法在其他模块中读取它。有什么办法吗?
尝试这个; 它可能有效:
module.exports = app => {
app.on(["pull_request.opened"], async context => {
let id = "some string";
//Just return the id, if you want to export more than one thing(id), you can use an object.
return id;
});
};
//Usage
//Where_i_use_it.js
const MyApp = require("./path/to/MyApp");
console.log(MyApp()); // ==> "some string" ```