• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

269
Views
Cómo filtrar datos de blogs para no agregar blogs vacíos o blogs con títulos vacíos

Aquí está el controlador:

importar API desde '../scripts/api.js' controlador de clase {

 constructor(model, view) { this.model = model this.view = view this.author=window.location.search.substr(10), this.view.handleShowForm() } //a function to get the data from the api fetch() { API.readAll('https://blog-server-rbk.herokuapp.com/api/blogs',function (data) { console.log('data: data sent',data) this.model.addBlogs(data) ; }) }

y la clase modelo con el método addBlogs, el problema está ahí, que debería agregar blogs al estado

 class Model { constructor() { //a state of the model this.blogs = [] } //this function should filter to not add empty blogs addBlogs(blogs) { blogs.filter(element => element.body.length==0 || element.title.length==0) this.blogs = blogs; }

}

exportar modelo predeterminado

about 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error