Skip to content

Commit add870b

Browse files
authoredMay 30, 2022
Add files via upload
1 parent 4d47911 commit add870b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
 

‎api/demo.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const fs = require('fs')
2+
3+
// const data = fs.readFileSync('./hello.txt', 'utf8')
4+
// console.log(data);
5+
6+
module.exports = (req, res) => {
7+
8+
fs.writeFileSync('./hello.txt', 'hello world', err => {
9+
if (err) {
10+
console.error(err)
11+
return
12+
}
13+
//文件写入成功。
14+
})
15+
16+
const data = fs.readFileSync('./hello.txt', 'utf8')
17+
18+
res.json({
19+
data
20+
})
21+
}

1 commit comments

Comments
 (1)

vercel[bot] commented on May 30, 2022

@vercel[bot]
Please sign in to comment.