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

194
Views
Cómo puedo personalizar axios en Vue

Escribí una respuesta con interceptores axios y envié el valor de retorno de esta respuesta a un archivo js llamado handleResponse. Este archivo js toma el valor de retorno y me devuelve un resultado. Si obtengo un error, lo descarto para rechazarlo.

 const instance = axios.create({ baseURL: apiName === "" ? process.env.VUE_APP_API_URL : process.env.VUE_APP_API_URL + apiName, withCredentials: false, headers: headers }); instance.interceptors.response.use( (response) => handleResponse(response), (error) => console.log(error) );

Mi archivo handleResponse js dentro de los interceptores es el siguiente

 export const handleResponse = (response) => { return new Promise((resolve) => { if (response.data["Success"]) resolve(response.data["Payload"]); else { let msg = ""; if (response.data["Information"]) msg = response.data["Information"]; showError(msg); reject(response); } }); };

Aquí hago que caiga en catch donde llamo a la API cuando pasa a la operación de rechazo.

 const cancelStorageTransfer = () => { return StorageTransferRequestService.cancelStorageTransfer(selectedStorageTransfer.value.Id) .then(() => { showSuccess("Transfer İptal İşlemi Başarıyla Gerçekleşti") storageTransferRequestSummary() }).catch(response => { showError(response.data.Information) }) }

Llamo a la API aquí, pero no quiero usar el catch. Pero cuando no lo uso, aparece el error "Uncauth (en promesa)" en la pantalla de registro.

Aquí, ¿cómo puedo hacer si usar la captura a mi voluntad?

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