My externaljsfile.JS looks like this:
"use strict";
const fsLibrary = require('fs');
function save_installform() {
alert("Step1");
fsLibrary.writeFile('/home/pi/newfile.txt', "Hello world.", (error) => {
alert("Error");
});
alert("Written");
};
When calling it with node externaljsfile.js
on my raspberry pi it works and creates the text file.
But when including it with src
in my HTML server and then calling the function save_installform()
with a button, there it only shows "Step 1" as alert like coded and breaks after. No "Error" or "Written" alert and no file.
Is this a permission problem or something like that?