Skip to content
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

Unable to save. Error:callback is not a function #1

Open
tkodev opened this issue Jan 19, 2017 · 1 comment
Open

Unable to save. Error:callback is not a function #1

tkodev opened this issue Jan 19, 2017 · 1 comment

Comments

@tkodev
Copy link

tkodev commented Jan 19, 2017

Code:

var editor = require('front-matter-editor');
var mdPath = "/Users/sysuser/Google Drive/projects/public/code/htko/site-base/scripts/README.md";
editor.read(mdPath).data(function(data,matter){
  data.photo.unshift( data.cover );
  delete data.cover;
  matter.data = data;
}).save(mdPath, {prefix:"test-"});

Error:

/Users/sysuser/Google Drive/projects/public/code/htko/site-base/scripts/node_modules/front-matter-editor/index.js:65
      callback(err, data);
      ^

TypeError: callback is not a function
    at fs.writeFile (/Users/sysuser/Google Drive/projects/public/code/htko/site-base/scripts/node_modules/front-matter-editor/index.js:65:7)
    at fs.js:1305:7
    at FSReqWrap.oncomplete (fs.js:123:15)
@gbirke
Copy link

gbirke commented Mar 23, 2018

This happens because the saving of the changed frontmatter fails and the example code does not provide an error handler. Try the following last line:

}).save(mdPath, {prefix:"test-"}, function(err, data) {
    if (err) {
        console.log( 'Could not write to ' + mdPath, err );
    }
});

The error should then be logged and you can find out what it was.

gbirke added a commit to gbirke/front-matter-editor that referenced this issue Mar 23, 2018
Add callback to example call of `.save()`

This will improve errors like the ones mentioned in
saltfactory#1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants