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

226
Visualizações
¿Cómo devolver el token como valor? Nodo js

¿Como puedó resolver esté problema? Hice una solicitud de publicación para obtener el token, pero cuando lo devuelvo, regresa como indefinido, pero cuando lo imprimo, muestra que el token está bien.

 function getToken() { // The req.query object has the query params that // were sent to this route. We want the `code` param axios({ // make a POST request method: "post", // to the Github authentication API, with the client ID, client secret // and request token url: ` https://backstage.taboola.com/backstage/oauth/token?client_id=${clientID}&client_secret=${clientSecret}&grant_type=client_credentials`, // Set the content type header, so that we get the response in JSOn headers: { accept: "application/json", }, }).then((response) => { // Once we get the response, extract the access token from // the response body accessToken = response.data.access_token; //console.log(accessToken); return(accessToken); }); };
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Podrías hacer algo como esto

 async function getToken() { // The req.query object has the query params that // were sent to this route. We want the `code` param const response = await axios({ // make a POST request method: "post", // to the Github authentication API, with the client ID, client secret // and request token url: ` https://backstage.taboola.com/backstage/oauth/token?client_id=${clientID}&client_secret=${clientSecret}&grant_type=client_credentials`, // Set the content type header, so that we get the response in JSOn headers: { accept: "application/json", }, }); return response.data.access_token }; const token = await getToken(); console.log(token) // more https://www.w3schools.com/js/js_promise.asp
about 4 years ago · Santiago Trujillo 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