Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

170
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda