Skip to content

Commit cb5e79a

Browse files
author
Invers3
committed
Update addpost.js
Testing
1 parent 5fa6562 commit cb5e79a

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

addpost.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
const fs = require('fs');
2+
const path = require('path');
23

34
const newPost = {
45
title: 'Mi primer post',
56
content: 'Este es el contenido de mi primer post'
67
};
78

8-
fs.writeFile('post.json', JSON.stringify(newPost), (err) => {
9-
if (err) {
10-
console.error(err);
11-
} else {
12-
console.log('Archivo post.json creado exitosamente');
13-
}
14-
});
9+
fs.writeFileSync(path.join(__dirname, 'hello_post.json'), JSON.stringify(newPost), 'utf8');
10+
console.log('Archivo post.json creado exitosamente');

0 commit comments

Comments
 (0)