const fs = require('fs'); fs.readFile('file.txt', 'utf8', (err, data) => { if (err) throw err; console.log(data); });
const fs = require('fs'); fs.readFile('file.txt', 'utf8', (err, data) => { if (err) throw err; console.log(data); });
const http = require('http'); http.get('http://example.com', (res) => { let data = ''; res.on('data', (chunk) => { data += chunk; }); res.on('end', () => { console.log(data); }); });
const mysql = require('mysql'); const connection = mysql.createConnection({ host: 'localhost', user: 'root', password: 'password', database: 'mydb' }); connection.connect(); connection.query('SELECT * FROM users', (error, results, fields) => { if (error) throw error; console.log(results); }); connection.end();
本文为翻滚的胖子原创文章,转载无需和我联系,但请注明来自猿教程iskeys.com