Skip to content

Commit

Permalink
fixed bugs after last merging
Browse files Browse the repository at this point in the history
  • Loading branch information
RuslanaLogosha committed Nov 18, 2020
1 parent 5668566 commit 7f41f36
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "./sass/main.scss";
// import "./js/modalFilmCard.js";
// import "./js/modalOpen.js";
// import "./js/cardFetc.js";
import "./js/modalFilmCard.js";
import "./js/modalOpen.js";
import "./js/cardFetc.js";
import "./js/pagination.js";
6 changes: 3 additions & 3 deletions src/js/apiServis.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default class NewApiService {
constructor() {
this.searcgQuery = '';
this.searchQuery = '';
}
fetchTrendingArticles() {
const url = `https://api.themoviedb.org/3/trending/all/day?api_key=d91911ebb88751cf9e5c4b8fdf4412c9`;
Expand All @@ -11,7 +11,7 @@ export default class NewApiService {
});
}
fetchFilmsSearch() {
const url = `https://api.themoviedb.org/3/search/movie?api_key=d91911ebb88751cf9e5c4b8fdf4412c9&query=${searcgQuery}`;
const url = `https://api.themoviedb.org/3/search/movie?api_key=d91911ebb88751cf9e5c4b8fdf4412c9&query=${searchQuery}`;
return fetch(url)
.then(response => response.json())
.then(data => {
Expand All @@ -24,4 +24,4 @@ export default class NewApiService {
set query(newQuery) {
this.searchQuery = newQuery;
}
}
}
21 changes: 2 additions & 19 deletions src/js/cardFetc.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,18 @@

import filmsCardTpl from '../templates/card-films.hbs';
import NewApiService from './apiServis';

const refs = {
cardContainet: document.querySelector(".js-card"),
cardContainer: document.querySelector('.js-card'),
};
const newApiService = new NewApiService();

fetch(
`https://api.themoviedb.org/3/trending/all/day?api_key=d91911ebb88751cf9e5c4b8fdf4412c9`
)
.then((response) => response.json())
.then((data) => {
renderFilmsCard(data.results.map((d) => d));
});

renderFilmsCard(data.results.map((d) => d));

function renderFilmsCard(info) {
const markup = filmsCardTpl(info);
refs.cardContainet.insertAdjacentHTML("beforeend", markup);
console.log(markup);
}

render();

function render() {
newApiService.fetchTrendingArticles().then(renderFilmsCard);
}

function renderFilmsCard(articles) {
refs.cardContainet.insertAdjacentHTML('beforeend', filmsCardTpl(articles));
refs.cardContainer.insertAdjacentHTML('beforeend', filmsCardTpl(articles));
// console.log(filmsCardTpl(articles));
}

0 comments on commit 7f41f36

Please sign in to comment.