jiaola / marc4js

A Node.js API for handling MARC
Apache License 2.0
38 stars 7 forks source link

Question about Transformer #6

Closed librarywebchic closed 5 years ago

librarywebchic commented 6 years ago

Sorry if this is a newbie question. I'm trying to transform a record into "Text" and have that text be assigned to a variable as a string so I can return it in an HTML template. However I keep ending up with a TextTransformer object. I'm assuming this is because the transformation hasn't "finished". Suggestions on how to fix this.

    let record_s = marc4js.transform(this.record, {toFormat: 'text'}, function(err, output) {
        return output;
    });
    console.log(record_s);
jiaola commented 6 years ago

The output is accessible inside the callback function. Try this:

    marc4js.transform(this.record, {toFormat: 'text'}, function(err, output) {
        console.log(output);
    });