Good Evening
Can you please send me the reference code for movie finder project. As I make a code for it but the code is not working properly.
Movie Finder using BOLT IOT module
HTML Code :-
Movie FinderMovie Finder
Search<div id="movieList"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/boltiot-py/1.0.2/bolt.min.js"></script>
<script src="script.js"></script>
JavaScript (script.js):-
const boltApiKey = ‘YOUR_BOLT_API_KEY’;
const deviceName = ‘YOUR_BOLT_DEVICE_NAME’;
const searchMovies = async () => {
const searchInput = document.getElementById(‘searchInput’).value;
// Make a request to the Bolt IoT device
const response = await boltCommand(`movie:${searchInput}`);
// Parse the response
const movieData = JSON.parse(response.value);
// Display the movie results
const movieList = document.getElementById('movieList');
movieList.innerHTML = '';
movieData.forEach(movie => {
const movieItem = document.createElement('div');
movieItem.innerHTML = `<h3>${movie.title}</h3>
<p>${movie.year}</p>
<p>${movie.genre}</p>`;
movieList.appendChild(movieItem);
});
};
const boltCommand = async (command) => {
const bolt = new Bolt();
try {
await bolt.apiKey(boltApiKey);
await bolt.device(deviceName);
const response = await bolt.digitalWrite('1', 'HIGH');
await delay(1000);
const data = await bolt.analogRead('A0');
const value = JSON.parse(data.value);
await bolt.digitalWrite('1', 'LOW');
return value;
} catch (error) {
console.error('Bolt IoT error:', error);
throw error;
}
};
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
Hey is this code fine ?