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

276
Views
Mutiple Axios return no puede devolver el valor pero en cosole está llegando

Múltiples retornos de Axios no pueden devolver el valor, pero en la consola viene la primera función que puede devolver los datos> la segunda y la tercera no pueden hacerlo>

<la primera función puede devolver los datos> <la segunda y la tercera no pueden hacerlo>

 async getdata() { let url = `xxxxxxxx`; this.axiosConfig = { withCredentials: false, maxRedirects: 3 }; let config: AxiosRequestConfig = { ...this.axiosConfig }; //axios.defaults.headers.common = { 'Authorization': 'Bearer ' + this.token } var result = await axios.get(url, config); console.log(result.data); // --------------> data is coming here return result.data; //------------>able to return the data from here } async getfame() { var res = await this.getdata() res.map(async(item: any) => { let url = `xxxxxxxx`; this.axiosConfig = { withCredentials: false, maxRedirects: 3 }; let config: AxiosRequestConfig = { ...this.axiosConfig }; //axios.defaults.headers.common = { 'Authorization': 'Bearer ' + this.token } var result1 = await axios.get(url, config); console.log(result1.data); // -----------------> data coming here return result1.data; //------------> not able to return the data from here //return axios.get<string>(url, config); }) } async getfix() { var res1 = await this.getdata() res1.map(async(item: any) => { let url = `xxxxxxxx`; this.axiosConfig = { withCredentials: false, maxRedirects: 3 }; let config: AxiosRequestConfig = { ...this.axiosConfig }; //axios.defaults.headers.common = { 'Authorization': 'Bearer ' + this.token } var result2 = await axios.get(url, config); console.log(result2.data); // -----------------> data coming here return result2.data; //------------> not able to return the data from here //return axios.get<string>(url, config); //-------------> tried this way but still not coming }) }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

En su segunda y tercera funciones, está devolviendo esas llamadas axios dentro de un mapa de matriz. La función externa no devuelve nada.

Si agrega un retorno antes de cada llamada .map() , las funciones devolverán una matriz de los resultados esperados.

 async getfame() { var res = await this.getdata() return res.map(async(item: any) => { /* ... */ return result1.data; }) } async getfix() { var res1 = await this.getdata() return res1.map(async(item: any) => { /* ... */ return result2.data; }) }
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!