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

169
Visualizações
How do I organise API function calls from different files?

I am trying to automatically update a bearer key which is found in login.js and have it be used to in a new axios instance in customer.js.

I am struggling to find a way to implement the function from the login.js and use it within customer.js before a new instance is created.

Login.js

async function Login(){
const Bearerget = await axios.post("https://login.salesforce.com/services/oauth2/token", config.data)
  const Bearer = `Bearer ${Bearerget.data.access_token}`
  console.log(Bearer)
  return `${Bearer}`
}

Customer.js

const login = require("./login");

Bearer = await login.Login()

const SalesforceClient = axios.create( {
  baseURL: `url`,
  timeout: 100000,
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': Bearer
}
});

async function Customers(){
//Code 
};

Customers()

What I get from the output is:

  • Goes into the login.js
  • Begins Customer()
  • then Bearer key is printed

How do I run login.js, get the bearer key from the function, and then have it be updated in the axios instance in customer.js?

about 4 years ago · Juan Pablo Isaza
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