Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

233
Visualizações
Formting ' nodepad file in Node.js

i need help with format of write text to nodepad file in node js. below is my code

const fs = require('fs');
    fs.writeFile('write.txt', '', err => {});
    var text = [];
    var max_iteration = 226;
    
    for (let i = 101; i < max_iteration; i++) {
      if (i == 126) i = 201;
    
      let html = `[${i}](endpoint-internal-d70)
      auth = ${i}
      aors = ${i}callerid = voicebot101 <101>
      
      [${i}](auth-userpass)
      password = ${i}
      username = ${i}

      [${i}] (aor-single-reg)`;
     text.push(html);
     if (i + 1 === max_iteration){
         display(text);
         console.log('Last loop:', i + 1);
      }
    }
    function display(text) {
      fs.writeFile('write.txt', JSON.stringify(text), err => {
         if (err) {
          console.log('Error writing file', err);
        } 
    else {
         console.log('Successfully wrote file');
        }
      });
    }

and i get something like this :["[101](endpoint-internal-d70)\n auth = 101\n aors = 101callerid = voicebot101 <101>\n \n...

i except remove white white characters from file and format text somethng like this:

["[101](endpoint-internal-d70)
      auth = 101
        aors = 101callerid = voicebot101 <101>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The string counts the indents as well, so remove the indent to fix the weird formatting.

let html =
`[${i}](endpoint-internal-d70)
auth = ${i}
aors = ${i}callerid = voicebot101 <101>

[${i}](auth-userpass)
password = ${i}
username = ${i}

[${i}] (aor-single-reg)`;
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda