Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
Almacenar response.data en una variable global

Estoy tratando de almacenar response.data en una variable que luego se puede usar fuera de su alcance, sin embargo, parece que siempre vuelve como indefinido.

Como puede ver en el código, las primeras llamadas axios devuelven un token y luego quiero poder usar este token dentro de los encabezados de la llamada POST.

 const server = () => { var token; axios.get('http://xxxxx').then( response => { token = response.data; } ); var configuration = { configToken: token }; async function login() { return fetch('https://xxxx', { method: 'POST', headers: { Authorization: `Bearer ${configuration.configToken}`, }, }) } login(); }; export default server;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

solicitud de axios que envíe dependiendo de la ruta del servidor. comprueba si tu servidor es https o http

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!