Skip to content
Sign UpLog In
Profile icon

Anonymous Anonymity

@AAnonymity
Repls
Community
AAnonymity
AAnonymity
shared a Post
4 years ago
Can you change a server side variable through client side? Node.js
Can you change a server side variable through client side? Node.js I have been searching for how to do this in Google and Stack Overflow for many day
mwilki7
mwilki7
I'm not sure how, at first glance, how to change server variables but the first thing I would try is build some sort of interface to change the server: example: client: function changeServerDate(date) { // send date over socket to server } server: var serverdate; socketthingy.on("changeDate", function(date) { serverdate = date; }); `4 years ago
JustARatherRidi
JustARatherRidi
Sure you can, but it depends on what sort of server you've got running and what data you're looking to send. Could you perhaps share a link to your code?4 years ago
AAnonymity
AAnonymity
shared a Post
4 years ago
fs.readFile() showing weird string to console in Node Js I am trying to read a text file and print out the results in the console, but whenever I try,
FS
Node.js
vedprad1
vedprad1
The solution is simple. When fs.readFile() only has two parameters, it will return a buffer. The solution is to add a parameter between the file name and the callback, like this: const fs = require(‘fs’); fs.readFile(‘text.txt’, ‘utf-8’ (err, data) => { console.log(data); }); If this answers your question, please check the checkmark on the left side of this message. Thanks and Good Luck!4 years ago