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

236
Views
¿Cómo puedo pasar un mensaje de error del backend del servidor al frontend de vue?

Estoy trabajando en el manejo de errores para una aplicación integrada en Vue/Vuetify. Estoy usando paginación externa para una tabla de datos que se vincula a una API que solo permite una cantidad determinada de visitas en un período de tiempo. Por eso, estoy tratando de pasar y mostrar un error de "Demasiadas solicitudes" en la interfaz para los usuarios cuando alcanzan ese límite.

Sin embargo, el problema que tengo es pasar ese error del servidor backend al frontend. Cuando falla en la parte delantera, solo da un error de 500. Sin embargo, el registro del servidor me está dando el error real. ¿Cómo puedo hacer que eso pase? A continuación se muestra el código javascript relevante del servidor y el front-end.

Nota: he estado usando eventbus para mostrar errores a lo largo del proyecto. Pero hasta ahora, no he tenido que pasar ninguno de atrás hacia adelante.

Servidor back-end

 module.exports = { async find(ctx) { var page = ctx.query.page; var key = ''; var locale = ({ location: '', location_type: '', page: page }); const sdk = require('api')('@'); try { var response = await sdk.auth(key)['grants_funders'](locale); } catch (err) { console.log(err); } ; // .then(res => console.log(res)) // .catch(err => console.error(err)); // console.log(response); return response } };

INTERFAZ

 export default { name: "Search", components: {}, props: ["funderDirectories", "serverItemsLength"], data() { return { page: 1, usericon: usericon, greentick: greentick, listicon: listicon, training: training, keyword: null, funderHeaders: [ { text: "Organization", value: "funder_name" }, { text: "City", value: "funder_city" }, { text: "Country", value: "funder_country" }, { text: "Count", value: "grant_count" }, ], myloadingvariable: false, pageCount: 1, itemsPerPage: 25, }; }, watch: { page() { Vue.$funderService.find({ page: this.page }).then((res) => { this.funderDirectories = res.data.rows; this.serverItemsLength = res.data.total_hits; }); }, }, methods: {}, computed: { filteredFunderDirectories() { if (!this.keyword) { return this.funderDirectories; } return this.funderDirectories.filter( (q) => q.funder_name.toLowerCase().indexOf(this.keyword.toLowerCase()) !== -1 ); }, }, };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Al final lo descubrí. agregó lo siguiente a la captura de backend

 return ctx.send({errorStatus:"Too Many Requests. Please Wait"},429)

Y pude llamar

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!