How to append a file in Node JS?

< 1 min readTo append data to a file in Node.js, you can use the fs (file system) module and the fs.appendFile() function. The fs.appendFile() function takes a file path and a string or Buffer as arguments, and asynchronously writes the data to the end of the file. If the file does not exist, it will be created….

Read More

How to parse JSON in Node js?

< 1 min readTo parse a JSON string in Node.js, you can use the JSON.parse() function. This function takes a JSON string as an argument and returns a JavaScript object or array constructed from the JSON string. Here’s an example of how to parse a JSON string: In this example, we parse a JSON string that represents an…

Read More

How to do Base64 encoding in Node.js?

< 1 min readTo Base64-encode a string in Node.js, you can use the Buffer class and its .toString() method. Here’s an example: You can also use the Buffer.from() method to decode a Base64-encoded string: Alternatively, you can use the built-in Buffer global and the .toString() method to achieve the same results: Note: The Buffer class was designed to…

Read More