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

123
Visualizações
How can I get d value from process.stdout.write(d)

I have that 'd' where is stored the access token, how can I get this value from him, if I'm using console.log(d) I'm getting this:

 <Buffer 7b 22 61 63 63 65 73 73 5f 74 6f 6b 65 6e 22 3a 22 65 61 38 30 66 32 30 35 38 38 32 37 34 64 37 32 62 61 64 66 30 36 31 37 64 36 37 62 36 65 34 38 22 ... 362 more bytes> 

I tried with toString(),str='',str+=d but I can't get it

const auth=()=>{
    const data=querystring.stringify({
        grant_type: 'client_credentials',
        client_id: 'x',
        client_secret: 'x',
    })
    var options = {
      port:443,
      host: 'rest.sandbox.eu.zuora.com',
      path:'/oauth/token',
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Content-Length': data.length
       },
       method: 'POST',
    };
    const req=https.request(options,(res)=>{
    
        res.on('data', (d) => {
         process.stdout.write(d)
         }).on('end',()=>{
             console.log("Yay");
         });
    })
    req.write(data)
    req.end()
    }
    auth()
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Try something like this (not tested)

const auth=()=>{
    const data=querystring.stringify({
        grant_type: 'client_credentials',
        client_id: 'x',
        client_secret: 'x',
    })
    var options = {
      port:443,
      host: 'rest.sandbox.eu.zuora.com',
      path:'/oauth/token',
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Content-Length': data.length
       },
       method: 'POST',
    };
    const req=https.request(options,(res)=>{
    
        let body = []
        res.on('data', (d) => {
            body.push(d)
        }).on('end',()=>{
            try {
                console.log(JSON.parse(Buffer.concat(body).toString()));
            } catch(e) {
                console.log('some error')
            }
         });
    })
    req.write(data)
    req.end()
    }
    auth()
about 4 years ago · Juan Pablo Isaza Relatório

0

I'm not sure how you are using toString, but if I invoke toString(), as

theString = d.toString()

it works for me.

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