I'm using vanilla Javascript with Node (HTTP) for server side and XMLHttpRequest for client side. Not sure how i could send an object that i've read on the server to the client.
For example i've this server code, to read the data and store it on data array to send later to the client:
data = []
fs.readFile("./client.json", function(err, jsonData){
if(err){
throw err;
}else{
data.push(JSON.parse(jsonData));
}
});
Now i'm kinda lost of how client side would be to GET the data array. I've tried this but couldn't get any
let xhttp = new XMLHttpRequest();
xhttp.open("GET", "http://localhost:3000/data", true);
xhttp.send(null);
I don't want to use Fetch nor Express. using HTTP for learning purpose.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.