I wanted to execute swi prolog code in a react/typescript component, where I got the error "tau_file_system is not defined". My code looks like this (the code is from the tau-prolog github page):
import { Button } from "@mui/material";
import pl from "tau-prolog";
function PrologTest() {
const onClick = () =\> {
const session = pl.create();
session.consult(
"likes(sam, salad).
likes(dean, pie).
likes(sam, apples).
likes(dean, whiskey).",
{
success: function () {
console.log("YES");
},
error: function (err: any) {
console.log("NO");
},
}
);
session.query("likes(sam, X).", {
success: function (goal: any) {
console.log("YES");
},
error: function (err: any) {
console.log("NO");
},
});
};
return (
<div className="container"\>
<Button onClick={onClick}\>XSD TO JSOn\</Button\>
</div\>
);
}
export default PrologTest;
I looked at the documentation and the issues of the project, but could not find where my problem could be (I am still a beginner with js/ts, nodejs etc).
Do any of you have any idea how I can fix the problem?