How to use js to read the contents of a txt file and assign the contents to variables (of type string)

how to use js to read the contents of a txt file and assign the contents to a variable (of type string)

Dec.12,2021

it is easiest to directly call the method of node.js 's built-in module fs to read the contents of the file:

const fs = require("fs");
const path = "./xxx.txt"; // text
const isExist = fs.existsSync(path); // 
const data = isExist ? fs.readFileSync(path, "utf-8") : "";
console.log(data);
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31a97-2bdc8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31a97-2bdc8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?