Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

use node js to check if a json file exists

const fs = require('fs')

const path = './file.txt'
//Async method
fs.access(path, fs.F_OK, (err) => {
  if (err) {
    console.error(err)
    return
  }

  //file exists
})
Source by flaviocopes.com #
 
PREVIOUS NEXT
Tagged: #node #js #check #json #file #exists
ADD COMMENT
Topic
Name
2+5 =