I ve got code to open a websocket connection and want simply put out a public readable textfile on the webconsole. I’ ll attach the code, the sharing for test.txt and the console output so far. any help appreciated.
<!doctype html>
<!-- websocket test location https://www.serverproject.de/etc/solid/socket/test.html -->
<html>
<head><meta charset="utf-8"/></head>
<script>
var socket = new WebSocket('wss://testpro.solidweb.org/', ['solid.0.1.0']);
console.log("solidweb socket definition done", socket)
socket.onopen = function() {
this.send('sub https://testpro.solidweb.org/public/ctest/test.txt');
console.log("solidweb socket sub sent", socket)
};
socket.onmessage = function(msg) {
if (msg.data && msg.data.slice(0, 3) === 'pub') {
console.log("solidweb message:",msg)
// resource updated, refetch resource
}
};
function display(msg){
let url = msg.data.substring(4, msg.data.length)
console.log(url)
fetch(url)
.then( r => r.text() )
.then( t => console.log(t) )
fetch(url, {
headers: {"Content-type": "text/plain; charset=UTF-8"},
method: 'GET'
})
.then(response => console.log(response.text()))
.catch((error) => {
console.error('Error:', error);
});
}
//var text="";
//display(text);
</script>
</html>
at David how do I call the functions in question ?

[edit] I’ ve played around with the brackets and don’ t know how function display is called…