Hi guys,

I need a bit of help to understand how to access  getTiddler  method from a 
javascript library

When I develop *macro* (module-type) I use this.wiki. filterTiddlers  (...) 
methods and all works fine when I invoke this macro from a tiddler script

But I would like to develop a javascript library that is intended to be 
used by different macros. This library will need to access a Data Tiddler 
(as a DB "backend")

So I created a javascript code and set its module-type to *library*
The code is the following

(function(){
class Hero {
    constructor(name, level) {
var stats_tiddler_title = "Stats_report"; // a backend tiddler that 
contains the stats reports (as field value)
var stats_tiddler_filter = "[["+stats_tiddler_title+"]]";
var stats_tiddlers = this.wiki.filterTiddlers(stats_tiddler_filter);
        this.name = name;
        this.level = level;
console.log("   Class created. Value:"+this.level);
    }
getName() {
console.log("   getName !!!!!. Name:"+this.name);
}
}
exports.Hero = Hero;

})();

>From my macro javascript I tried to call this library 

var Hero = require('$:/plugins/vpl/vpl_test_class.js').Hero;
const hero1 = new Hero('Varg', 1);

But I get the error
Uncaught TypeError: Cannot read properties of undefined (reading 
'filterTiddlers')

I'm blocked .... Can someone help & guide me on the proper way to do that ?

Thanks very much for your help

Regards

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywikidev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywikidev/5465e8b4-fea7-46f4-8868-be9c94a4e821n%40googlegroups.com.

Reply via email to