Hi, I want to read the file to launch the control version for my game
I have difficulty reading file
This is my code :
function readFile (logger: nkruntime.Logger , nk: nkruntime.Nakama) {
let sample : string = nk.fileRead("sample.json");
logger.debug(sample);
logger.debug(JSON.parse(sample));
}
This is my compiled code with line numbers :
136 : function readFile(logger, nk) {
137 : var sample = nk.fileRead("sample.json");
138 : logger.debug(sample);
139: logger.debug(JSON.parse(sample));
140: }
This is sample.json file :
{
"version": "1.0.0"
}
This is my log file :
{"level":"debug","ts":"2022-02-14T12:21:21.045+0330","caller":"server/runtime_javascript_logger.go:104","msg":"{\r\n \"version\": \"1.0.0\"\r\n}"}
{"level":"error","ts":"2022-02-14T12:21:21.046+0330","caller":"server/runtime_javascript.go:1509","msg":"Failed to eval JavaScript modules.","error":"TypeError: invalid format argument: must be a string\n\tat github.com/heroiclabs/nakama/v3/server.(*jsLogger).Constructor.func3.4 (native)\n\tat readFile (index.js:139:26(21))\n\tat InitModule (index.js:124:11(42))\n"}
{"level":"error","ts":"2022-02-14T12:21:21.046+0330","caller":"server/runtime.go:598","msg":"Error initialising JavaScript runtime provider","error":"TypeError: invalid format argument: must be a string\n\tat github.com/heroiclabs/nakama/v3/server.(*jsLogger).Constructor.func3.4 (native)\n\tat readFile (index.js:139:26(21))\n\tat InitModule (index.js:124:11(42))\n"}
{"level":"fatal","ts":"2022-02-14T12:21:21.046+0330","caller":"v3/main.go:146","msg":"Failed initializing runtime modules","error":"TypeError: invalid format argument: must be a string\n\tat github.com/heroiclabs/nakama/v3/server.(*jsLogger).Constructor.func3.4 (native)\n\tat readFile (index.js:139:26(21))\n\tat InitModule (index.js:124:11(42))\n"}
Thanks for pointing me to how I can read the “version”?