-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hexo API incorrect report in use“Cannot read property 'f' of undefined” #2851
Comments
Hey. You missed the second argument of the hexo.call('generate', {}).then(function(){ // ...}); Updated your code. var express = require('express');
var router = express.Router();
var Hexo = require('hexo');
router.get('/', function(req, res, next) {
var hexo = new Hexo(process.cwd(), {});
hexo.init().then(function(){
hexo.watch().then(function(){
hexo.call('generate', {}).then(function(){
return hexo.exit();
}).catch(function(err){
return hexo.exit(err);
});
});
});
res.send('hexo g ture');
});
module.exports = router; |
@NoahDragon Maybe we should do |
@bhaskarmelkani agree, we should document that. |
I will prefer adding default |
Linked a PR if we decide to go other way. |
The common node.js function will have signature
see https://nodejs.org/api/fs.html#fs_fs_readdirsync_path_options. I suggest we keep consistency with node.js convention. @bhaskarmelkani Could you file a PR to add defaults? Thank you |
Thank yours, I can now use it |
Yeah will do it asap. |
Closing in reference to #PR |
I want to call the HEXO API in the Express.js framework as a hook,But it is wrong.
Perhaps due to the documentation is too simple and lead developers to understand the error caused the error.
I can not get any answer from Google. so,How should I call api?
This is my fail code and console output error:
and console error
and this is my file tree
The text was updated successfully, but these errors were encountered: