Due to a request, I added another function to #LivePrinter called lib.getdata(). It gets data from any HTTP server using GET or POST. It expects a JSON object with a "data" key that contains an array of [x,y,z] points. See below to use:
liveprinter code to get data from a remote server using POST:
const data = await lib.getdata("http://localhost:8888/data");
loginfo(JSON.stringify(data));
// loop through data
for (let p of data) {
loginfo(`${p}`);
let [x,y,z] = p;
loginfo(`moveto ${x},${y}`);
// move to coordinates from data
# mov2 x:x y:y
}
What's returned from the server http://localhost:8888/data with a POST command:
{ data: [
[0,0,0],
[1,1,1],
[2,2,2]
]
}