undefine in nodejs when creating folder

1

From the database I'm getting ip and id , and when I want to create a folder and put the ip as the name I get undefined and the folder is created but with the name undefined, inside of that folder I am creating a photo and the id is the name that I put and the file if it is created well, but the folder does not put the name of ip .

My code:

var dir = 'cr.${ip}';
  try {
    fs.mkdirSync(dir);
    require("fs").writeFile('${dir}/${_id}.jpg', binaryData, "binary", err =>
      console.log(err)
    )
  } catch(err) {
    if(err.code == 'EEXIST') {
      require("fs").writeFile('${dir}/${_id}.jpg', binaryData, "binary", err =>
        console.log(err)
      )
    } else {
      console.log(err);
    }
  }
    
asked by Exbaby 23.07.2017 в 18:21
source

0 answers