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

182
Views
¿Por qué axios no regresa correctamente?

Estoy tratando de reemplazar una fetch con axios . Sigo sin definir en el registro de mi consola.

 async componentDidMount() { console.log('app mounted'); const tokenString = sessionStorage.getItem("token"); const token = JSON.parse(tokenString); let headers = new Headers({ "Accept": "application/json", "Content-Type": "application/json", 'Authorization': 'Bearer ' + token.token }); const response = await axios({ method: 'get', url: Config.apiUrl + `/api/Orders/GetAllInvoices`, headers: { "Accept": "application/json", "Content-Type": "application/json", 'Authorization': 'Bearer ' + token.token } }); console.log(`axios: ${response.json}`) this.setState({ invoiceList: response.json }); //const response = await fetch(Config.apiUrl + `/api/Orders/GetAllInvoices`, { // method: "GET", // headers: headers //}); //const json = await response.json(); //console.log(json); //this.setState({ invoiceList: json }); ...

... la fetch comentada está funcionando. Acabo de agregar el .json aunque axios no debería necesitarlo. De ninguna manera funciona. ¿Qué estoy haciendo mal?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

¿Incluso console.log(response) solo para ver qué hay dentro?

Supongo que no, porque la response es un objeto que no tiene una clave json . Deberías usar response.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!