Chào mọi người, hiện tại mình đang cố làm 1 thanh tìm kiếm, dữ liệu là fetch về từ api, nhưng gặp lỗi chỗ x.includes. Nó báo lỗi là x.includes is not a function, mình đã lên mạng kiểm tra nhưng mò mãi vẫn không hiểu lí do lỗi là gì nên đăng lên đây mong được chỉ điểm
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div>
<input type="text" name="Thanh tìm kiếm" placeholder="Nhập tên phim" id="thanhtimkiem">
<input type="button" name="Nút tìm kiếm"
id="nuttimkiem" value="Tìm">
<input type="button" name="Nút hiển thị"
id="nuthienthi" value="Hiển thị">
</div>
<div id="Title"></div>
<div id="Result"></div>
<script type="text/javascript" >
let API = 'https://api.themoviedb.org/3/search/movie?api_key=f0f3c0668b8133927ac87e3dca27b62a&query=%24i&page=1&fbclid=IwAR3bOPqImv9FYuSwa9RgTE1NQ4ngjfAcMDXZEK15-EmUG0U-k0uFZUpr0vA';
const inputBar = document.querySelector('#thanhtimkiem');
const inputBtn = document.querySelector('#nuttimkiem');
inputBtn.addEventListener('click',find);
const outputBtn = document.querySelector('#nuthienthi');
function find() {
let name = document.getElementById('thanhtimkiem').value;
fetch(API)
.then(response => {
return response.json();
})
.then(films => {
const result = films.results;
console.log(result);
const resultFind = result.filter(x => {x.includes(name)});
document.getElementById('Result').innerHTML = resultFind;
})
}
</script>
</body>
</html>