JS/TP04/EX01/js/controller.js
2024-03-08 16:34:15 +01:00

31 lines
551 B
JavaScript

class Controller {
constructor(view,model){
this.view = view
this.model = model
this.loading = false
this.lastSearch = null
this.error = null
this.results = []
this.view.setLoading(false)
this.view.bindSearch(this.search.bind(this))
}
reset() {
this.loading = false
this.error = null
this.results = []
}
async search(searchMovie) {
let data = await this.model.getMovies(searchMovie);
console.log(data);
if (data.Response === "True"){
this.view.renderList(data.Search);
}
}
}
export default Controller